TITLE: Evaluate $\int_0^{\infty} \frac{\log(x)dx}{x^2+a^2}$ using contour integration
QUESTION [10 upvotes]: This question is Exercise 10 of Chapter 3 of Stein and Shakarchi's Complex Analysis.

Show that if $a>0$, then
$$\int_0^{\infty}  \frac{\log(x)dx}{x^2+a^2}=\frac{\pi \log(a)}{2a}.$$

The hint is to integrate over the boundary of the domain
$\{z: \epsilon<|z|<R, \Im(z)>0\}.$
I'm not sure what to do with the integral over the outer arc.

REPLY [2 votes]: Since the OP requests evaluation by contour integration, we proceed accordingly.
We begin by analyzing the contour integral $I$ as given by
$$I=\oint_C \frac{\log^2(z)}{z^2+a^2}\,dz$$
where $C$ is the classical "keyhole" contour with the "keyhole" aligned with the branch cut taken along the non-negative real axis.  
Then, we have using the residue theorem
$$\begin{align}
I&=2\pi i \left(\frac{(\log(a)+i\pi/2)^2}{2ia}+\frac{(\log(a)+i3\pi/2)^2}{-2ia}\right)\\\\
&=-i 2\pi^2 \frac{\log(a)}{a}+\frac{2\pi^3}{a} \tag 1
\end{align}$$
We also have 
$$\begin{align}
I&=\int_0^\infty \frac{\log^2(x)}{x^2+a^2}\,dx+\int_\infty^0 \frac{(\log(x)+i2\pi)^2}{x^2+a^2}\,dx\\\\
&=i4\pi \int_0^\infty \frac{\log(x)}{x^2+a^2}\,dx+4\pi^2 \int_0^\infty \frac{1}{x^2+a^2}\,dx\\\\
&=-i4\pi \int_0^\infty \frac{\log(x)}{x^2+a^2}\,dx+ \frac{2\pi^3 }{a} \tag 2
\end{align}$$
Now, set real and imaginary parts of $(2)$ and $(3)$ equal to arrive at the result
$$\bbox[5px,border:2px solid #C0A000]{\int_0^\infty \frac{\log(x)}{x^2+a^2}\,dx=\frac{\pi \log(a)}{2a}}$$