# Contour integration of logarithmic functions: $\int_0^{\infty} \! \frac{\ln(x)}{x^2+a^2} \, \mathrm{d}x$ [duplicate]

I am trying to solve using contour integration $$\int_0^{\infty} \! \frac{\ln(x)}{x^2+a^2} \, \mathrm{d}x = \frac{\pi \ln(a)}{2a}$$ Where $a>0$. I am stuck in finding roots and residue for the given problem. Can somebody help?
Consider the function $f(z) = \frac{\ln^2(z)}{z^2+a^2}$ where the $\ln$ has its branch cut on $[0,+\infty).$ You can remark that $ia$ and $-ia$ are two simple poles of this function. Hence the residues can be computed as follows $$\text{Res}(f,ia) = \lim_{z\to ia} (z-ia)f(z) = \lim_{z\to ia} \frac{\ln^2(z)}{z+ia}=\frac{(\ln|ia|+i\text{arg}(ia))^2}{2ia}=\frac{(\ln(a)+i\pi/2)^2}{2ia}.$$ With the same method, we find $$\text{Res}(f,-ia) = \lim_{z\to -ia} (z+ia)f(z) = \lim_{z\to -ia} \frac{\ln^2(z)}{z-ia}=-\frac{(\ln|-ia|+i\text{arg}(-ia))^2}{2ia}=\frac{(\ln(a)+i3\pi/2)^2}{2ia}.$$ Then I suggest you to take the rest of the computations by your own and you will naturally see why I have to consider $\ln^2(z)$ instead of $\ln(z).$