TITLE: Why does $\int_0^\infty\frac{\ln (1+x)}{\ln^2(x)+\pi^2}\frac{dx}{x^2}$ give the Euler-Mascheroni constant?
QUESTION [11 upvotes]: I'd like to see the reason why $$\int\limits_{0}^{\infty}\frac{\mathrm{ln}(1+x)}{\mathrm{ln}^2(x)+\pi^2}\frac{\mathrm{d}x}{x^2}=\gamma$$
where $\gamma$ is the Euler-Mascheroni constant.
I don't have any 'neat tricks' for this expression... would appreciate any!

REPLY [13 votes]: Here is an approach.
We may observe that we have

$$
\int_0^{+\infty}\frac 1{(x+t)(\log^2 x +\pi^2)}dx=\frac 1{\log t}+\frac 1{1-t},\quad 0<t<1.\tag1
$$

Proof. Let $t$ be any real number such that $0<t<1$. Set
$$
f(z):=\frac 1{(z+t)(\log z +i\pi)}
$$ where $\log$ is the determination of the logarithm defined on the complex plane cut along the positive real axis. Consider
$$\oint_{C}  f(z)\: dz$$
where $C$ is a keyhole contour of radius $R$ about the positive real axis, that has four components, consisting of a small semi-circle $\Gamma_\epsilon$ about the origin of radius $\epsilon$, a line segment $L^+$ above the positive real axis close to it, an almost full circle $\Gamma_R$ and a line segment $L^-$ below and parallel to the positive real axis in the negative sense. Then
$$\oint_{C}  f(z)\: dz=\int_{\large \Gamma_\epsilon} f(z)\:dz +\int_{\large L^+} f(z)\:dz+ \int_{\large \Gamma_R} f(z)\:dz+\int_{\large L^-} f(z)\:dz$$ 
As $\epsilon \to 0$, the first integral vanishes because the integrand is $\mathcal{O}\Big(\dfrac \epsilon {\log \epsilon}\Big)$ uniformly on the compact set $[-\pi/2,\pi/2]$; as $R \to +\infty$, the third integral vanishes because the integrand is $\mathcal{O}\Big(\dfrac 1 {\log R}\Big)$ uniformly on the compact set $[0,2\pi]$. 
Thus, as $\epsilon \to 0$ and as $R \to +\infty$, the contour integral is equal to
$$
\int_0^{+\infty}\frac{1}{x+t}\left(-\frac 1{\log x +i \pi}+\frac 1{\log x -i \pi}\right)dx=
2i\pi \int_0^{+\infty}\frac 1{(x+t)(\log^2 x +\pi^2)}dx.$$
By the residue theorem, the contour integral is also equal to $2 i \pi$ times the sum of the residues at the poles $z=-t$, $z=-1$: 
$$\begin{align}
\text{Res}_{\large z=-t}(f):&=\lim_{z\to -t}\,(z+t)f(z)=\frac 1{\log t}\\
\text{Res}_{\large z=-1}(f):&=\lim_{z\to -1}\,(z+1)f(z)=\frac 1{1-t}
\end{align}
$$
giving 
$$
2i\pi \int_0^{+\infty}\frac 1{(x+t)(\log^2 x +\pi^2)}dx=2i\pi \Big( \frac 1{\log t}+\frac 1{1-t}\Big)
$$
which is $(1)$.
Then, integrating both sides of $(1)$ with respect to $t$ from $0$ to $1$, we get on the left hand side, using Fubini's theorem applied to positive integrands: 
$$
\int_{0}^{\infty}\frac{\log(1+1/x)}{\log^2 x+\pi^2}dx\stackrel{\large x\to1/x}=\int_{0}^{\infty}\frac{\log(1+x)}{\log^2 x+\pi^2}\frac{dx}{x^2} \tag2
$$
and we get on the right hand side the classic integral

$$
\int_0^{1}\left(\frac 1{\log t}+\frac 1{1-t}\right)dt= \gamma, \tag3
$$

leading to the desired result.