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.
If you stick to the complex-analytic technique, here is one possible solution: Choose the branch cut of complex logarithm as $[0, \infty)$ so that $\Im\log z \in [0, 2\pi)$. Then consider the function
$$ f(z) = \frac{\log^2 z}{z^2 + a^2}, $$
where $\log^2 z = (\log z)^2$ is the square of the logarithm. Then using the keyhole contour $C$ described as in Figure 1,
$\hskip{2in}$
$\hskip{1in}$ Figure 1. Image from @Daniel Fischer♦'s answer in this posting.
we find that
\begin{align*} \oint_{C} f(z) \, \mathrm{d}z &= 2\pi i \left( \underset{z=ia}{\operatorname{Res}} f(z) + \underset{z=-ia}{\operatorname{Res}} f(z) \right) \\ &= \frac{\pi}{a} \left( \left(\log a + \frac{i\pi}{2} \right)^2 - \left(\log a + \frac{3i\pi}{2} \right)^2 \right) \\ &= \frac{2\pi^3}{a} - \frac{2\pi^2 i \log a}{a}. \tag{1} \end{align*}
On the other hand, shrinking the inner circle $\gamma$ to the origin and letting the outer circle $\Gamma$ to the infinity, it follows that
$$ \oint_{C} f(z) \, \mathrm{d}z \xrightarrow[\substack{\gamma \to 0 \\ \Gamma \to \infty}]{} \int_{0}^{\infty} \frac{\log^2 x}{x^2 + a^2} \, \mathrm{d}x - \int_{0}^{\infty} \frac{(\log x + 2\pi i)^2}{x^2 + a^2} \, \mathrm{d}x. \tag{2} $$
Comparing imaginary parts of $\text{(1)}$ and $\text{(2)}$, it follows that
$$ \int_{0}^{\infty} \frac{\log x}{x^2 + a^2} \, \mathrm{d}x = \frac{\pi \log a}{2a}. $$