Improper integral with log and absolute value: $\int^{\infty}_{0} \frac{\log |\tan x|}{1+x^{2}} \, dx$ How do you show that $$ \int^{\infty}_{0} \frac{\log |\tan x|}{1+x^{2}} \, dx = \frac{\pi}{2} \log (\tanh 1)\, ?$$
I know that the integral converges since $\log |\tan x| = \frac{1}{2} \log(\tan^{2}x)$, and $\log (\tan^{2} x)$ behaves like $2 (-1)^{n} \log \left(x-\frac{n \pi}{2} \right)$ near $x= \frac{n \pi}{2}$. Thus the singularities at $x= \frac{n \pi}{2}$ are integrable.

How about:
$$
    \int_0^\infty \frac{\log | \tan x |}{1+x^2} \mathrm{d} x = \frac{1}{2} \int_0^\infty \frac{\log \tan^2 x }{1+x^2} \mathrm{d} x = \frac{1}{4} \int_{-\infty}^\infty \frac{\log \tan^2 x }{1+x^2} \mathrm{d} x  \tag{$\ast$}
$$
Writing the integral over $\mathbb{R}$ as the average of integrals over $\mathbb{R} + i \epsilon$ and $\mathbb{R} - i \epsilon$ and using $\vert \tan(z) \vert^2 = \frac{\sin^2(2 x) + \sinh^2(2y)}{(\cos(2x) + \cosh(2y))^2} \to_{y \to \pm \infty} 1$ we can complete the integration contours and apply the residue theorem:
$$ \begin{eqnarray}
 \int_{-\infty}^\infty \frac{\log \tan^2 x }{1+x^2} \mathrm{d} x &=& \frac{1}{2} \int_{-\infty +i 0}^{\infty +i 0} \frac{\log \tan^2 x }{1+x^2} \mathrm{d} x + \frac{1}{2} \int_{-\infty-i 0}^{\infty - i 0} \frac{\log \tan^2 x }{1+x^2} \mathrm{d} x  \\
 &=& \frac{1}{2} \cdot 2 \pi i \operatorname{Res}_{x=i}\frac{\log \tan^2 x }{1+x^2} - \frac{1}{2} \cdot 2 \pi i \operatorname{Res}_{x=-i}\frac{\log \tan^2 x }{1+x^2} \\
  &=& 2 \pi \log \tanh(1)
\end{eqnarray}
$$
Combining with eq. $(\ast)$:
$$
  \int_0^\infty \frac{\log | \tan x |}{1+x^2} \mathrm{d} x = \frac{\pi}{2} \log \tanh(1)
$$
