TITLE: Definite integral using the method of residues
QUESTION [17 upvotes]: I have the following integral to compute: $$ \int_{0}^{\infty}\frac{\log x}{1 + x^2}\text{d}x.$$ 
Following is my attempt:
$$
 \int_{0}^{\infty}\frac{\log x}{1 + x^2}\text{d}x  = \int_{0}^{1}\frac{\log x}{1 + x^2}\text{d}x +  \int_{1}^{\infty}\frac{\log x}{1 + x^2}\text{d}x
.$$ 
But using the substitution $x=1/u$, we get:  $$\int_{0}^{1}\frac{\log x}{1 + x^2}\text{d}x= -\int_{\infty}^{1}\frac{1}{u^2}\cdot\frac{\log (1/u)}{1 + (1/u)^2}\text{d}u = -\int_{1}^{\infty}\frac{\log u}{1 + u^2}\text{d}u.$$ 
Hence $$ \int_{0}^{\infty}\frac{\log x}{1 + x^2}\text{d}x = -\int_{1}^{\infty}\frac{\log u}{1 + u^2}\text{d}u +  \int_{1}^{\infty}\frac{\log x}{1 + x^2}\text{d}x = 0$$ since $u$ is a dummy variable.  
What I'd like to do now is to compute the same integral using the method of residues(I have no experience with it) and I'd gladly appreciate any kind of help.
Thanks.

REPLY [7 votes]: Define a branch cut for $\log$ going from the origin to the lower half plane, and restrict to the branch where $\log(z) = \ln|z|$ for $z>0$ and $\log(z) = \ln|z| + \pi i$ for $z <0$. Then we have:
$$
\int_{-\infty}^\infty\frac{\log(z)}{1+z^2}dz=2\int_{0}^\infty\frac{\log(z)}{1+z^2}dz+\pi i\int_{0}^\infty\frac{1}{1+z^2}dz
$$
We can evaluate the left hand size by closing the contour with a great semicircle in the upper half plane. Since $f(z)|z|\rightarrow 0$ as $|z| \rightarrow 0$, we can ignore the contribution from the singularity at the origin. Likewise since $f(z)|z|\rightarrow 0$ as $|z| \rightarrow +\infty$ we can ignore the contribution from the great semicircle in the upper half plane. The function has a one singularity in the upper half plane, at $z=i$. So by the residue theorem:
$$
\begin{equation}
\int_{-\infty}^\infty\frac{\log(z)}{1+z^2}dz= 2 \pi i \ \mbox{Res}\left[ \frac{\log(z)}{1+z^2}; z = i \right]= 2 \pi i \left[ \frac{\log(z)}{i+z}\right]_{z=i}= 2 \pi i \frac{\pi i /2}{i+i}  = \frac{\pi^2 i}{2}
\end{equation}
$$
And since $\int_{0}^\infty\frac{1}{1+z^2}=\pi/2$, the original equation becomes:
$$
\frac{\pi^2 i}{2}=2\int_{0}^\infty\frac{\log(z)}{1+z^2}dz+\pi i\left(\frac{\pi}{2}\right)
$$
$$
\Rightarrow \int_{0}^\infty\frac{\log(z)}{1+z^2}dz=0
$$