2. Four functions
$$
\begin{array}{l}
y=\sin |x|, y=\cos |x|, \\
y=|\tan x|, y=-\ln |\sin x|
\end{array}
$$

with a period of $\pi$, which is monotonically decreasing on $\left(0, \frac{\pi}{2}\right)$ and is an even function is ( ).
(A) $y=\sin |x|$
(B) $y=\cos |x|$
(C) $y=|\tan x|$
(D) $y=-\ln |\sin x|$
2. D.

Since $y=\sin |x|$ is not a periodic function, option A is incorrect;

Since $y=\cos |x|$ is a periodic function with the smallest positive period of $2 \pi$, option B is incorrect;

Since $y=|\tan x|$ is monotonically increasing in $\left(0, \frac{\pi}{2}\right)$, option C is incorrect;
The function $y=-\ln |\sin x|$ meets the requirements of the problem.