Solve $\int_{0}^{\infty}\frac{\ln(2x)}{4+x^2}dx$ by contour integration I'm a little stuck with this one. I've found the singularities to be at $\pm 2i$ and $0$ (branch point). So far, using a branch cut at $2\pi$ I've found that
$$\int_{0}^{\infty}\frac{\ln(2r)}{4+r^2}dr+\int_{0}^{\infty}\frac{\ln(2r)+2\pi i}{4+r^2}dr = 2I+\int_{0}^{\infty}\frac{2\pi i}{4+r^2}dr$$
And 
$$\int_{0}^{\infty}\frac{2\pi i}{4+r^2}dr = \text{Res}(r=2i) \\ = -2\pi^2\lim_{r\to2i}\frac{r-2i}{(r-2i)(r+2i)} = \frac{i}{2}\pi^2$$
My problem is that the answer I found is completely imaginary, and I'm not sure how that's possible given that the original function is real. Any help is appreciated.
 A: Consider 
$$f(z) = \frac{\log(2z)}{z^2+4}$$
By using a key-hole integral with branch-cut on positive axis we should get 
$$\int^\infty_0 \frac{\log(|2x|)}{x^2+4}\,dx + \int_{\infty}^{0} \frac{\log(|2x|)+2\pi i}{x^2+4}\,dx =2\pi i \sum \mathrm{Res}(f,z_0)$$
We see that the first and second integrals will cancel. Now to avoid that consider
$$f(z) = \frac{\log(2z)^2}{z^2+4}$$
By using a key-hole integral with branch-cut on positive axis we should get 
$$\int^\infty_0 \frac{\log^2(|2x|)}{x^2+4}\,dx + \int^0_{\infty} \frac{(\log(|2x|)+2\pi i)^2}{x^2+4}\,dx =2\pi i \sum \mathrm{Res}(f,z_0)$$
$$\int^\infty_0 \frac{\log^2(|2x|)}{x^2+4}\,dx - \int_0^{\infty} \frac{(\log(|2x|)+2\pi i)^2}{x^2+4}\,dx =2\pi i \sum \mathrm{Res}(f,z_0)$$
Now you can see that $\log^2(2x)$ will be cancelled and we are left out with $\log(2x)$.

Another approach
Integrate around a big half-circle indented at 0 where the branch cut is chosen on the imaginary axis then for
$$f(z) = \frac{\log(2z)}{z^2+4}$$
we have only one pole at $z = 2i$
$$\int_{-\infty}^0 \frac{\log|2x|+\pi i}{x^2+4}\,dx +\int^{\infty}_0 \frac{\log|2x|}{x^2+4}\,dx = 2\pi i \,\mathrm{Res}(f,2i)$$
$$2\int^\infty_0 \frac{\log(2x)}{x^2+4}\,dx + \pi i\int^\infty_0\frac{1}{x^2+4}\,dx = 2\pi i \,\mathrm{Res}(f,2i) $$
Note that 
$$\mathrm{Res}(f,2i) = \lim_{z \to 2i} (z-2i) \frac{\log(2z)}{(z-2i)(z+2i)} = \frac{\log(4i)}{4i} = \frac{\log(4)+(\pi i)/2}{4i}$$
$$2\int^\infty_0 \frac{\log(2x)}{x^2+4}\,dx + \pi i\int^\infty_0\frac{1}{x^2+4}\,dx = \pi \frac{\log(4)+(\pi i)/2}{2} $$
By comparison we have 
$$\int^\infty_0 \frac{\log(2x)}{x^2+4}\,dx = \frac{\pi}{2} \log(2)$$
A: 
METHODOLOGY $1$:  COMPLEX ANALYSIS

As already established in the answer left by @ZaidAlyafeai, the classical approach begins by analyzing the contour integral 
$$I=\oint_C \frac{\log^2(2z)}{z^2+4}\,dz$$
where $C$ is the "keyhole" contour with the keyhole taken along the positive real axis.  In that case $0\le \arg(z)<2\pi$.  Then, we have
$$\begin{align}
\color{blue}{\int_0^\infty \frac{\log^2(2x)}{x^2+4}\,dx-\int_0^\infty\frac{(\log(2x)+i2\pi)^2}{x^2+4}\,dx}&=\color{red}{2\pi i \text{Res}\left(\frac{\log^2(2z)}{z^2+4}, z=\pm i2\right)}\\\\
&=\color{red}{2\pi i\left(\frac{\log^2(4i)}{4i}+\frac{\log^2(-4i)}{-4i}\right)}\\\\
&=\color{red}{\frac{\pi}{2}\left((\log(4)+i\pi/2)^2-(\log(4)+i3\pi/2)^2\right)}\\\\
\color{blue}{4\pi^2\int_0^\infty\frac{1}{x^2+4}\,dx-i4\pi\int_0^\infty\frac{\log(2x)}{x^2+4}\,dx}&=\color{red}{\frac{\pi}{2}\left(2\pi^2-i2\pi\log(4)\right)}\tag 1
\end{align}$$
where we find by setting real and imaginary parts of $(1)$ equal
$$\int_0^\infty \frac{1}{x^2+4}\,dx=\frac{\pi}{4}$$
and

$$\bbox[5px,border:2px solid #C0A000]{\int_0^\infty\frac{\log(2x)}{x^2+4}\,dx=\frac{\pi\log(2)}{2}} \tag 2$$



METHODOLOGY $2$:  REAL ANALYSIS
I thought it might be instructive to present an approach that relies on real analysis only. 

To proceed, we begin by enforcing the substitution $x\to 4/x$.  Then, we have
$$\begin{align}
\int_0^\infty \frac{\log(2x)}{x^2+4}\,dx&=\int_0^\infty \frac{\log(8/x)}{(4/x)^2+4}\,\frac{4}{x^2}\,dx\\\\
&=4\log(2)\int_0^\infty\frac{1}{x^2+4}\,dx-\int_0^\infty \frac{\log(2x)}{x^2+4}\\\\
2\int_0^\infty \frac{\log(2x)}{x^2+4}\,dx&=4\log(2)\int_0^\infty\frac{1}{x^2+4}\,dx\\\\
\int_0^\infty \frac{\log(2x)}{x^2+4}\,dx&=2\log(2)\int_0^\infty\frac{1}{x^2+4}\,dx\\\\
&=\frac{\pi\log(2)}{2}
\end{align}$$
agreeing with the result in $(2)$ as expected!
