Evaluate $\int_0^\infty \frac{(\log x)^2}{1+x^2} dx$ using complex analysis How do I compute 

$$\int_0^\infty \frac{(\log x)^2}{1+x^2} dx$$

What I am doing is take 
$$f(z)=\frac{(\log z)^2}{1+z^2}$$
and calculating 
$\text{Res}(f,z=i) = \dfrac{d}{dz} \dfrac{(\log z)^2}{1+z^2}$
which came out to be $\dfrac{\pi}{2}-\dfrac{i\pi^2}{8}+\dfrac{i\pi}{2}$
Im not too sure how to move on from here. the given answer is $\dfrac{\pi^3}{8}$
Any help will be appreciated. thank you in advanced.

For this integral, you want to define you branch cut along the negative x axis and use a contour with a semi circle around the origin. 

Also, note we are taking the real Cauchy Principal value.
Then
$$
\int_0^{\infty}\frac{(\ln(z))^2}{1+z^2}dz = \int_{\Gamma}f(z)dz+\int_{\gamma}f(z)dz + \int_{-\infty}^0f(z)dz + \int_0^{\infty}f(z)dz
$$
Let $R$ be the radius of big semi circle, $\Gamma$ and $\delta$ the radius of the small semi circle $\gamma$. When $R\to\infty$, $\int_{\Gamma}\to 0$ and $\int_{\gamma}\to 0$ when $\delta\to 0$ by the estimation lemma. 
Then
$$
\int_{-\infty}^0f(z)dz + \int_0^{\infty}f(z)dz = 2\pi i \sum\text{Res}_{\text{UHP}}
$$
where UHP is the upper half plane. There is only one pole in the upper half plane and that is $z = i$
$$
\text{Re PV}\biggl[\int_{-\infty}^0\frac{(\ln|z| + i\pi)^2}{z^2+1}dz + \int_0^{\infty}\frac{(\ln|z| + i\cdot 0)^2}{z^2+1}dz\biggr] = 2\pi i\sum\text{Res}_{\text{UHP}}
$$
Recall that $\ln(z) = \ln|z| + i\arg(z)$.
Can you take it from here?

Mouse over for solution.

 \begin{align}\text{Re PV}\biggl[\int_{-\infty}^0\frac{\ln^2|z| + 2\pi i\ln|z| - \pi^2}{z^2 + 1}dz +\int_0^{\infty}\frac{\ln^2|z|}{z^2 + 1}dz\biggr]&= 2\pi i\lim_{z\to i}(z - i)\frac{(\ln|z| + i\pi/2)^2}{z^2+1}\\2\int_0^{\infty}\frac{\ln^2(x)}{x^2 + 1}dx - \pi^2\int_0^{\infty}\frac{dx}{x^2+1} &= -\frac{\pi^3}{4}\\2\int_0^{\infty}\frac{\ln^2(x)}{x^2 + 1}dx - \frac{\pi^3}{2} &= -\frac{\pi^3}{4}\\\int_0^{\infty}\frac{\ln^2(x)}{x^2 + 1}dx &= \frac{\pi^3}{4} - \frac{\pi^3}{8}\\&= \frac{\pi^3}{8}\end{align}

