Consider

$\displaystyle \displaystyle f(z)=\frac{\log(z)}{z^2+a^2}$

and for $\displaystyle 0<\varepsilon<R$ define the contour $\displaystyle \Omega_{\varepsilon,R}$ to be

$\displaystyle \displaystyle \Omega_{\epsilon,R}=\Gamma_R\cup\gamma_{\varepsilo n}\cup[-R,-\varepsilon]\cup[\varepsilon,R]$

Where $\displaystyle \Gamma_R$ is the half-annulus $\displaystyle \Gamma_R=\varepsilon<|z|<R$ and $\displaystyle \gamma_{\varepsilon}$ is the semi-circle of radius $\displaystyle \varepsilon$ centered at $\displaystyle 0$. It's evident that

$\displaystyle \displaystyle \left|\int_{\gamma_{\varepsilon}}f(z)\text{ }dz\right|\to0\quad \varepsilon\to 0$

and

$\displaystyle \displaystyle \left|\int_{\Gamma_R}f(z)\text{ }dz\right|\leqslant \frac{|\log(R)|+\pi}{R^2-1}\pi R\to 0\quad R\to\infinity$

But, by the residue theorem

$\displaystyle \displaystyle \int_{\Omega_{R,\varepsilon}}f(z)\text{ }dz=2\pi i \text{Res}\left(f;ia\right)=\frac{\pi}{a}\left(\lo g(a)+\frac{\pi i}{2}\right)$

And thus it follows that

$\displaystyle \displaystyle \int_{-\infty}^{\infty}\frac{\log(z)}{z^2+a^2}\text{ }dz=\frac{\pi}{a}\left(\log(a)+\frac{\pi i}{2}\right)$

But,

$\displaystyle \displaystyle \begin{aligned}\int_{-\infty}^{0}f(z)\text{ }dz &= \int_{-\infty}^{0}\frac{\log(-x)+\pi i}{x^2+a^2}\text{ }dx\\ &= \int_0^{\infty}\frac{\log(x)}{x^2+a^2}\text{ }dx+\frac{\pi^2 i}{2a}\end{aligned}$

From where it evidently follows that

$\displaystyle \displaystyle \int_0^{\infty}\frac{\log(x)}{x^2+a^2}\text{ }dx=\frac{\pi\log(a)}{2a}$