So I was trying to solve this integral (I'm not asking how to solve it) and I thought I did some progress but I can't figure out what I've done. (See below) This integral converges, and I got to something which is indeterminate plus another integral which I suppose is convergent. WolframAlpha shows that the numerical value of this last integral is the same as that of the original integral, so I suppose the indeterminate part should cancel to 0. However, I think I got $- \infty$, which doesn't make sense for what I said. Therefore, my question: Does the indeterminate part approach $- \infty$? Does it approach 0? How do you compute it? And anyway, is there anything wrong with my approach (something should definitely be wrong...) ?
$$\int_0^{\frac{\pi}{2}} \ln^2\left({\cos{x}}\right) = x \ln^2\left({\cos{x}} \right) \Big|_0^{\frac{\pi}{2}} +2 \int_0^{\frac{\pi}{2}} x \tan{x} \ln\left({\cos{x}}\right)dx = x \ln^2\left({\cos{x}} \right) \Big|_0^{\frac{\pi}{2}} +2 \int_{-\infty}^0 u \arccos\left({e^u}\right) du = x \ln^2\left({\cos{x}} \right) \Big|_0^{\frac{\pi}{2}} +2 \int_{-\infty}^0 u \left( \frac{\pi}{2} - \arcsin\left({e^u}\right)\right) du = x \ln^2\left({\cos{x}} \right) \Big|_0^{\frac{\pi}{2}} + \frac{\pi}{2} u^2 \Big|_{-\infty}^0 - 2\int_{-\infty}^0 u \arcsin\left({e^u}\right)du$$
First I did integration by parts and then change of variable $\ln\left(\cos{x}\right) = u$