Evaluating $\int _0^{\frac{\pi }{2}}x\cot \left(x\right)\ln ^2\left(\cos \left(x\right)\right)\:dx$ I want to evaluate $\displaystyle \int _0^{\frac{\pi }{2}}x\cot \left(x\right)\ln ^2\left(\cos \left(x\right)\right)\:dx$ but it's quite difficult.
I have tried to rewrite the integral as
$$\int _0^{\frac{\pi }{2}}x\cot \left(x\right)\ln ^2\left(\cos \left(x\right)\right)\:dx=\frac{\pi }{2}\int _0^{\frac{\pi }{2}}\tan \left(x\right)\ln ^2\left(\sin \left(x\right)\right)\:dx-\int _0^{\frac{\pi }{2}}x\tan \left(x\right)\ln ^2\left(\sin \left(x\right)\right)\:dx$$
I've also tried to integrate by parts in multiple ways yet I cant go forth with this integral, I also tried using the substitution $t=\tan{\frac{x}{2}}$ but cant get anything to work, I'll appreciate any sort of help.
I also tried using the classical expansion
$$\ln \left(\cos \left(x\right)\right)=-\ln \left(2\right)-\sum _{n=1}^{\infty }\frac{\left(-1\right)^n\cos \left(2nx\right)}{n},\:-\frac{\pi }{2}<x<\frac{\pi }{2}$$
But it only gets worse.

A quite elegant solution.
The fact
$$
\Im\left[\log^3\left(\frac{1+e^{2ix}}2\right)\right]=3x\log^2\cos x-x^3
$$
yields
$$
\int_0^{\pi/2}x\cot x\log^2\cos x~d x=\frac16\Im\left[\int_{-\pi/2}^{\pi/2}\cot x\log^3\left(\frac{1+\text e^{2ix}}2\right)d x\right]+\frac13\int_0^{\pi/2}x^3\cot x~d x
$$
The rest two integrals are easy.
$$
\begin{align}
&\int_{-\pi/2}^{\pi/2}\cot x\log^3\left(\frac{1+\text e^{2ix}}2\right)~d x
\\=&\oint\frac{z+1}{z-1}\log^3\left(\frac{1+z}2\right)~\frac{d z}{2iz}\quad z=e^{2ix}
\\=&2\pi~\text{Res}\left[\frac{z+1}{z-1}\log^3\left(\frac{1+z}2\right)~\frac{1}{2iz},0\right]
\\=&i\pi\log^32
\end{align}
$$
The contour is the unit circle with small perturbations near $z=\pm1$ .
$$
\begin{align}
&\int_0^{\pi/2}x^3\cot x~d x
\\=&x^3\log(2\sin x)\Big|_0^{\pi/2}-3\int_0^{\pi/2}x^2\log(2\sin x)d x
\\=&\frac{\pi^3}8\log2+3\int_0^{\pi/2}\sum_{n\ge1}\frac{\cos(2nx)}nx^2~d x
\\=&\frac{\pi^3}8\log2+3\sum_{n\ge1}\frac{\pi(-1)^n}{4n^3}
\\=&\frac{\pi^3}8\log2-\frac{9\pi}{16}\zeta (3)
\end{align}
$$
Where Fourier series of $\log(2\sin x)$ is applied.
Combine them and the result follows.
$$
\int_0^{\pi/2}x\cot x\log^2\cos x~d x=\frac{\pi^3}{24}\log2-\frac{3\pi}{16}\zeta (3)+\frac\pi6\log^32
$$
