Definite integral using the method of residues 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.
 A: 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
$$
A: Residue Approach
We will compute
$$\renewcommand{\Re}{\operatorname{Re}}\newcommand{\Res}{\operatorname*{Res}}
\int_\gamma\frac{\log(z)^2}{1+z^2}\,\mathrm{d}z\tag1
$$
where $\gamma$ is the keyhole contour
$$
[ri,R+ri]\cup\sqrt{R^2+r^2}e^{i\left[\tan^{-1}\left(\frac rR\right),2\pi-\tan^{-1}\left(\frac rR\right)\right]}\cup[R-ri,-ri]\cup re^{i\left[\frac{3\pi}2,\frac\pi2\right]}\tag2
$$
where $r\to0$ and $R\to\infty$. We will put the branch cut along the positive real axis. On the the upper side of the real axis, $\log(z)$ is $\log(\Re(z))$. On the lower side, it is $\log(\Re(z))+2\pi i$.
The integral counter-clockwise along $\gamma$ is
$$
\begin{align}
\int_\gamma\frac{\log(z)^2}{1+z^2}\,\mathrm{d}z
&=\int_0^\infty\frac{\log(x)^2-(\log(x)+2\pi i)^2}{1+x^2}\,\mathrm{d}x\\
&=\int_0^\infty\frac{4\pi^2-4\pi i\log(x)}{1+x^2}\,\mathrm{d}x\\
&=2\pi^3-4\pi i\int_0^\infty\frac{\log(x)}{1+x^2}\,\mathrm{d}x\tag3
\end{align}
$$
The integral is also equal to $2\pi i$ times the sum of the residues of $\frac{\log(z)^2}{1+z^2}$:
$$
\Res_{z=i}\left(\frac{\log(z)^2}{1+z^2}\right)=\frac{\pi^2i}8\tag{4a}
$$
$$
\Res_{z=-i}\left(\frac{\log(z)^2}{1+z^2}\right)=-\frac{9\pi^2i}8\tag{4b}
$$
Thus, the integral is $2\pi i\left(\frac{\pi^2i}8-\frac{9\pi^2i}8\right)=2\pi^3$. This, in conjunction with $(3)$ yields
$$
\int_0^\infty\frac{\log(x)}{1+x^2}\,\mathrm{d}x=0\tag5
$$

Non-Residue Approach
To get this directly, without contour integration or breaking up the interval of integration, substitute $x\mapsto\frac{1}{x}$:
$$
\int_0^\infty\frac{\log(x)}{1+x^2}\mathrm{d}x=-\int_0^\infty\frac{\log(x)}{1+x^2}\mathrm{d}x\tag6
$$
and therefore the integral is $0$.
A: In the book 'COMPLEX VARIABLES Introductions and Applications' page 247-248 Example 4.3.5, contains a complete answer to your question. He begins by evaluating $I=\int_{0}^{\infty}\frac{\log^{2}(x)}{1+x^2}dx$ and after a few steps, arrive at the following expression $2\int_{0}^{\infty}\frac{\log^{2}(x)}{1+x^{2}}dx +2\pi i\int_{0}^{\infty}\frac{\log(x)}{1+x^{2}}dx=\frac{\pi^3}{4}$. So  $$\int_{0}^{\infty}\frac{\log(x)}{1+x^{2}}=0.$$ I suggest reading! Any questions post to us.
