How to show that $\int_0^{\infty} dx \frac{\log{x}}{1+x^2}$ is zero using complex analysis I want to show this using contour integration, the appropriate contour is a keyhole I think.
 A: No hole is needed. This can be done using elementary real analysis techniques. We have
$$\underbrace{\int_1^{\infty} \dfrac{\log(x)}{1+x^2}dx = \int_1^0 \dfrac{\log(1/t)}{1+1/t^2} \dfrac{-dt}{t^2}}_{x=1/t} = -\int_0^1 \dfrac{\log(t)}{1+t^2}dt$$
Hence,
$$\int_0^{\infty} \dfrac{\log(x)}{1+x^2}dx = \int_0^1 \dfrac{\log(x)}{1+x^2}dx + \int_1^{\infty} \dfrac{\log(x)}{1+x^2}dx = 0$$
A: Outline for Contour integration: 
While this can almost certainly be solved more easily by substitution, here is an outline for how to do it with complex analysis. First, we will use the the branch of logarithm whose branch cut is the non-negative real axis, and then using a keyhole contour such as this one: 
 
Important: This idea frequently comes up when working with such integrals, but we need to examine the contour integral with the function $$\frac{\log^2 x}{1+x^2} \text{  instead of  }\frac{\log x}{1+x^2}$$ in order for the pieces on the opposite sides of the contour to cancel out and yield the correct final integral.
Here are the four steps to evaluating the integral:
Step 1: Show that the integral of $\frac{\log^2 x}{1+x^2} $ over the small circle of radius $\epsilon$ around $0$ will give a contribution tending to $0$ as $\epsilon\rightarrow 0$.
Step 2: Show that the integral of $\frac{\log^2 x}{1+x^2} $ over the large circle of radius $R$ will give a contribution tending to $0$ as $R\rightarrow \infty$.
Step 3: The sum of the residue at $-i$ and $i$ equals $$\sum\text{Res}=\frac{\log^{2}(i)}{2i}+\frac{\log^{2}(-i)}{-2i}=-\frac{\pi^{2}}{8i}+\frac{9\pi^{2}}{8i}=\frac{\pi^{2}}{i},$$
 and so $$2\pi i\sum\text{Res}=2\pi^{3}.$$
Step 4: For the final two pieces, their contribution is $$\lim_{\epsilon\rightarrow0}\lim_{R\rightarrow0}\left(\int_{0}^{R}\frac{\log^{2}(x+i\epsilon)}{1+(x+i\epsilon)^{2}}dx-\int_{0}^{R}\frac{\log^{2}(x-i\epsilon)}{1+(x-i\epsilon)^{2}}dx\right)$$ and since we chose the non-negative real axis as our branch cut, this equals $$=\int_{0}^{\infty}\frac{\log^{2}x}{1+x^{2}}dx-\int_{0}^{\infty}\frac{\left(\log x+2\pi i\right)^{2}}{1+x^{2}}dx=4\pi i\int_{0}^{\infty}\frac{\log x}{1+x^{2}}dx+4\pi^{2}\int_{0}^{\infty}\frac{1}{1+x^{2}}dx.
 $$
Putting this all together, we have that $$4\pi i\int_{0}^{\infty}\frac{\log x}{1+x^{2}}dx+4\pi^{2}\int_{0}^{\infty}\frac{1}{1+x^{2}}dx=4\pi i\int_{0}^{\infty}\frac{\log x}{1+x^{2}}dx+2\pi ^3=2\pi i\sum\text{Res}=2\pi^3,$$ and so we conclude that the integral equals $0$.
A: Using the ''keyhole'' contour $\Gamma$, i.e. a big circle of radius $M$, a small circle of radius $\varepsilon$ connected by two segments just above and below the positive real axis, and choosing the branch cut of the logarithm on the positive real axis, we have
$$
\oint_\Gamma \frac{\ln^2 z}{1+z^2}dz=i2\pi \left(\text{Res}\frac{\ln^2z}{1+z^2}\Big|_{z=e^{i\pi/2}}+\text{Res}\frac{\ln^2z}{1+z^2}\Big|_{z=e^{i3\pi/2}}\right)=\pi^3\left(\frac{9}{4}-\frac{1}{4}\right)=2\pi^3.
$$
Now, the integral on the big circle vanishes as $M\to\infty$, since the integrand falls off as $\ln^2 M/(1/M^2)$, and the integral on the small circle vanishes as $\varepsilon\to0$ since the $\varepsilon$ coming from the line element cancels the $\ln^2\varepsilon$ singularity; therefore in such limits
$$
2\pi^3 = 
\int_0^{+\infty}\frac{\ln^2x}{1+x^2}dx-\int_{0}^{+\infty}\frac{(\ln x+i2\pi)^2}{1+x^2}dx =
-i4\pi\int_{0}^{+\infty}\frac{\ln x}{1+x^2}dx+4\pi^2\int_{0}^{+\infty}\frac{1}{1+x^2}dx.
$$
Comparing real and imaginary parts
$$
\int_{0}^{+\infty}\frac{dx}{1+x^2} = \frac{\pi}{2}\\
\int_{0}^{+\infty}\frac{\ln x}{1+x^2}dx=0.
$$
Note that both results might have been proven via elementary integration:
$$
\int_{0}^{+\infty}\frac{dx}{1+x^2} = \tan^{-1}x\Big|_0^{+\infty}=\pi/2
$$ 
whereas letting $x=e^{t}$
$$
\int_{0}^{+\infty}\frac{\ln x}{1+x^2}dx = \int_{-\infty}^{+\infty}\frac{t}{1+e^{2t}}e^{t}dt
=
\int_{-\infty}^{+\infty}\frac{t}{e^{t}+e^{-t}}dt=0
$$
since the integrand is odd.
