How to evaulate $\int_0^{\infty}\frac{\ln x}{\sqrt{x}(x^2+a^2)^2}$ using contour integration I'm asked to calculate the following integral for which $0 \neq a \in \mathbb{R}$:
$$\int_0^{\infty}\frac{\ln x}{\sqrt{x}(x^2+a^2)^2}$$
I'm confused about which contour I should use, whether it should be a semi-circle deformed to avoid the origin, or a keyhole contour based on a similar question I found here: Calculating $\int_0^{\infty } \frac{\ln (x)}{\sqrt{x} \left(a^2+x^2\right)^2} \, \mathrm{d}x$ using contour integration (but this question did not go into detail about how the integration was carried out using the keyhole contour)
Also, after deciding on which contour to use, how do I proceed from there to evaluate this integral? I know that I would eventually have to use the Residue Theorem but how do I isolate the part of the contour only going from $0$ to $\infty$?
 A: We integrate with $a$ a positive real
$$f(z) = \frac{\mathrm{Log}(z)}{(z-ai)^2 (z+ai)^2}
\exp(-1/2\times \mathrm{Log}(z))$$
around a  keyhole contour  with the  slot on  the positive  real axis,
which  is also  where  the  branch cut  of  the  logarithm is  located
(argument of  the logarithm is  between $0$  and $2\pi$). Now  for the
large circle we get $\lim_{R\to\infty} 2\pi R \log R / \sqrt{R} /R^4 =
0$ so  there is no  contribution in the  limit.  For the  small circle
around the  origin we find  $\lim_{\epsilon\to\ 0} 2\pi  \epsilon \log
\epsilon /  \sqrt\epsilon /a^4 = 0$  so there is no  contribution here
either. 
We get for the upper line segment
$$\int_0^\infty \frac{\log x}{(x^2+a^2)^2}
\exp(-1/2\times \log x) \; dx$$
which is  our target  integral, call  it $J$.  The lower  line segment
contributes
$$-\int_0^\infty \frac{\log x + 2\pi i}{(x^2+a^2)^2}
\exp(-1/2\times \log x) \exp(-1/2\times 2\pi i) \; dx
\\ = \int_0^\infty \frac{\log x + 2\pi i}{(x^2+a^2)^2}
\exp(-1/2\times \log x) \; dx
\\ = J + 2\pi i \int_0^\infty \frac{1}{(x^2+a^2)^2}
\exp(-1/2\times \log x) \; dx = J + 2\pi i K$$
where $J$ and $K$ are real numbers. We thus have
$$2J + 2\pi i K = 2\pi i  \mathrm{Res}_{z=ai} f(z)
+ 2\pi i  \mathrm{Res}_{z=-ai} f(z)$$
or
$$J + \pi i K = \pi i  \mathrm{Res}_{z=ai} f(z)
+ \pi i  \mathrm{Res}_{z=-ai} f(z)$$
With this  setup we  do not actually  need to compute  $K$ as  it must
correspond  to the  imaginary part  of the  contribution from  the two
residues. We get for the first residue at $z=ai$ the derivative
$$\frac{1}{z} \frac{1}{(z+ai)^2} \exp(-1/2\times \mathrm{Log}(z))
-2 \mathrm{Log}(z) 
\frac{1}{(z+ai)^3} \exp(-1/2\times \mathrm{Log}(z))
\\ + \mathrm{Log}(z) \frac{1}{(z+ai)^2} 
\exp(-1/2\times \mathrm{Log}(z)) \times -\frac{1}{2} \frac{1}{z}.$$
With the branch of the logarithm we find $\mathrm{Log}(ai) =
\log a + \pi i/2$, getting
$$\frac{1}{\sqrt{a}} \exp(-\pi i/4)
\\ \times \left(\frac{1}{ai} \times - \frac{1}{4 a^2}
+ (2\log a + \pi i) \frac{1}{8 i a^3}
+ (\log a + \pi i/2) \times - \frac{1}{4 a^2} 
\times -\frac{1}{2 ai}\right)
\\ = \frac{1}{\sqrt{a}} \exp(-\pi i/4) \frac{1}{8i a^3}
(3\log a + 3\pi i/2 - 2).$$
We also have $\mathrm{Log}(-ai) = \log a + 3 \pi i/2$, getting
for the second residue at $z=-ai$
$$\frac{1}{\sqrt{a}} \exp(-3\pi i/4)
\\ \times \left(- \frac{1}{ai} \times - \frac{1}{4 a^2}
- (2\log a + 3\pi i) \frac{1}{8 i a^3}
+ (\log a + 3\pi i/2) \times - \frac{1}{4 a^2} 
\times \frac{1}{2 ai}\right)
\\ = \frac{1}{\sqrt{a}} \exp(-3\pi i/4) \frac{1}{8i a^3}
(- 3\log a - 9\pi i/2 + 2).$$
With $\exp(-\pi i/4) = 
\frac{\sqrt{2}}{2} - i \frac{\sqrt{2}}{2}$
and $\exp(-3\pi i/4) = 
-\frac{\sqrt{2}}{2} - i \frac{\sqrt{2}}{2}$
and factoring out $\frac{1}{\sqrt{a}} \frac{1}{8i a^3}$
we get three contributions, which are
$$\sqrt{2} (3\log a - 2) + 3\pi i (\sqrt{2} + i\sqrt{2}/2)$$
Combine these and multiply by $\pi i$ to get
$$\frac{\pi}{8\sqrt{a} a^3}
(\sqrt{2} (3\log a - 2) + 3\pi i (\sqrt{2} + i\sqrt{2}/2)).$$
We extract the real part as promised and obtain
$$\frac{\sqrt{2}\pi}{8\sqrt{a} a^3}
(3\log a - 2 - 3\pi/2)$$
or
$$\bbox[5px,border:2px solid #00A000]{
\frac{\pi}{4\sqrt{2} a^{7/2}}
\left(3\log a - 2 - \frac{3}{2}\pi\right).}$$
matching the result by @Jack D'Aurizio.
As a bonus we have shown that
$$\int_0^\infty \frac{1}{\sqrt{x} (x^2+a^2)^2} dx
= \frac{1}{\pi} \frac{\pi}{8\sqrt{a} a^3} 3\sqrt{2}\pi 
= \frac{3\pi}{4\sqrt{2} a^{7/2}}.$$
A: Define $\sqrt{z}$ and $\ln z$ with a branch cut at the positive $x$-axis. Integrate $$f(z) = \frac{\ln z}{\sqrt{z}(z^2+a^2)^2}$$ around keyhole contour. along upper $x$-axis is :
$$\int_{\gamma_1} f(z) dz = \int_0^{\infty}\frac{\ln x}{\sqrt{x}(x^2+a^2)^2} dx$$
along lower $x$-axis is:
$$\int_{\gamma_2} f(z) dz = \int_\infty^{0}\frac{\ln x+2\pi i}{-\sqrt{x}(x^2+a^2)^2} dx = \int_0^{\infty}\frac{\ln x+2\pi i}{\sqrt{x}(x^2+a^2)^2} dx$$
from which you recovered the original integral.
A: $\phantom{a}$ Dear audience, this is the new episode of Feynman's trick versus contour integration.

Our starting point is 
$$\forall \alpha\in(-1,1),\qquad \int_{0}^{+\infty}\frac{x^\alpha}{1+x^2}\,dx =\frac{\pi}{2\cos\tfrac{\pi\alpha}{2}}\tag{1}$$
which is a consequence of the substitution $\frac{1}{1+x^2}=u$, Euler's Beta function and the reflection formula for the $\Gamma$ function. We may introduce a further parameter $K>0$ and state
$$\forall \alpha\in(-1,1),\forall K>0,\qquad \int_{0}^{+\infty}\frac{x^\alpha}{K+x^2}\,dx =\frac{\pi K^{\frac{\alpha-1}{2}}}{2\cos\tfrac{\pi\alpha}{2}}\tag{2}$$
then differentiate both sides with respect to $K$:
$$\forall \alpha\in(-1,1),\forall K>0,\qquad \int_{0}^{+\infty}\frac{x^\alpha}{(K+x^2)^2}\,dx =\frac{\pi(1-\alpha) K^{\frac{\alpha-3}{2}}}{4\cos\tfrac{\pi\alpha}{2}}.\tag{3}$$
Let us differentiate both sides with respect to $\alpha$ (it is more practical to exploit $\frac{df}{dx}=f(x)\cdot\frac{d}{dx}\log f(x)$ to manipulate the RHS):
$$\int_{0}^{+\infty}\frac{x^\alpha\log(x)}{(K+x^2)^2}\,dx =\frac{\pi K^{\frac{\alpha-3}{2}}}{8\cos\tfrac{\pi\alpha}{2}}\left[(1-\alpha)\log K+\pi(1-\alpha)\tan\tfrac{\pi\alpha}{2}-2\right].\tag{4}$$
By evaluating $(4)$ at $K=a^2$ and $\alpha=-\frac{1}{2}$ we get:
$$\int_{0}^{+\infty}\frac{\log(x)}{\sqrt{x}(x^2+a^2)^2}\,dx =\frac{\pi |a|^{-7/2}}{4\sqrt{2}}\left[3\log|a|-\tfrac{3\pi}{2}-2\right].\tag{5}$$
