A tricky integration $I=\int _0 ^\infty \log\left(x+\frac{1}{x}\right)\frac{1}{1+x^2}dx$ What is $$I=\int _0 ^\infty \log\left(x+\frac{1}{x}\right)\frac{1}{1+x^2}dx$$  At first I thought it was easy but couldnt figure out a good substitution,then tried out IBP but that too leads to messy integrations then did $x\mapsto x^{-1}$ to get $\log(x+\frac{1}{x})\frac{x^2+1-1}{1+x^2}$ then split it to get $2I=\log(x+\frac{1}{x})$ i thought it was integrable and could get a definite value but Integral calculator says the function is divergent . So i am now in a dilemma whether the question is correct or am i missing some good substitution. Also seeing the limits of integration I am  thinking of using the concepts of limits .
 A: One may write
$$
I=\int _0^\infty \frac{\log(1+x^2)}{1+x^2}dx-\int _0^\infty \frac{\log x}{1+x^2}dx,
$$ by the change of variable $x \to 1/x$, one has
$$
\int _0^\infty \frac{\log x}{1+x^2}dx=-\int _0^\infty \frac{\log x}{1+x^2}dx=0,
$$ by the change of variable $x=\tan \theta$, one gets
$$
\int _0^\infty \frac{\log(1+x^2)}{1+x^2}dx=\!\int _0^{\large \frac{\pi}2} \!\frac{\log(\cos^{-2} \theta)}{1+\tan^2 \theta}(1+\tan^2 \theta)d\theta=-2\int _0^{\large \frac{\pi}2}\! \log(\cos \theta) \:d \theta=\pi \log 2,
$$ where we have used a well-known result.
Finally,

$$
I=\int _0^\infty \frac{\log \left(x+\frac1x \right)}{1+x^2}dx=\pi \log 2.
$$

A: Another method: Let
$$ I(\alpha)=\int _0 ^\infty \log\left(\alpha^2 x+\frac{1}{x}\right)\frac{1}{1+x^2}dx.$$
Then $I(1)=I, I(0)=0$. Note 
$$ I'(\alpha)=2\alpha\int _0 ^\infty \frac{x^2}{\alpha^2 x^2+1}\frac{1}{1+x^2}dx=\frac{\pi}{1+\alpha} $$
and hence
$$ I(1)=\int_0^1\frac{\pi}{1+\alpha}d\alpha=\pi\log2. $$
A: Letting x=\tan \theta yields
$$
\begin{aligned}
I &=\int_0^{\frac{\pi}{2}} \ln \left(\tan \theta+\frac{1}{\tan \theta}\right) d \theta \\
&=\int_0^{\frac{\pi}{2}} \ln \left(\frac{1}{\cos \theta \sin \theta}\right) d \theta\\ &=-\int_0^{\frac{\pi}{2}} \ln \cos \theta d \theta-\int_0^{\frac{1}{2}} \ln \sin \theta d \theta
\\&=\pi \ln 2
\end{aligned}
$$
where the last answer using the results $\int_0^{\frac{\pi}{2}} \ln \cos\theta d \theta =\int_0^{\frac{\pi}{2}} \ln \sin \theta d \theta =-\frac{\pi}{2} \ln 2$.
