Contour integration of $\frac{(\ln z)^2}{z^2+1} $ I'm supposed to take the principal branch of $\ln z$ and evaluate this integral:
$$ \oint \frac{(\ln z)^2}{z^2+1}  $$ 

Attempt
I suppose the integral they are talking about is something like this:

The simple poles are at $z=\pm i$, and since the contour doesn't include any of them the integral is zero.
Then this doesn't help part (c) at all..
 A: Along the upper half of $|z|=R$,
$$ \begin{align} \Big| \int_{C_{R}} f(z) \ dz \Big| &\le \int_{0}^{\pi} \Big| \frac{(\ln R + i \theta)^{2}}{R^{2}e^{2i \theta}+1} i Re^{i \theta} \Big| \ d \theta \\  &\le \pi R \frac{(\ln R + i \pi)^{2}}{R^{2}-1} \to 0 \ \text{as} \ R \to \infty \end{align}$$
And along the upper half of $|z|=r$,
$$ \Big| \int_{C_{r}} f(z) \ dz \Big| \le \pi r \frac{(\ln r + i \pi)^{2}}{1-r^{2}} \to 0 \ \text{as} \ r \to 0$$
So letting $R \to \infty$ and $r \to 0$,
$$ \begin{align} \int_{-\infty}^{0} \frac{(\log |x|+ i \pi)^{2}}{x^{2}+1} \ dx + \int_{0}^{\infty} \frac{\log^{2} x}{x^{2}+1} \ dx & = 2 \pi i \ \text{Res}[f(z),i] \\ &= 2 \pi i \lim_{z \to i} \frac{\log^{2} z}{z+i} \\ &= 2 \pi i \frac{(\log |i| + \frac{i \pi }{2})^{2}}{2i} \\  &= - \frac{\pi^{3}}{4} \end{align} $$
But making the substitution $u = - x$ in the first integral,
$$ \begin{align} \int_{-\infty}^{0} \frac{(\log |x|+ i \pi)^{2}}{x^{2}+1} \ dx &= \int_{0}^{\infty} \frac{(\log u + i \pi)^{2}}{u^{2}+1} \ du \\ &= \int_{0}^{\infty} \frac{\log^{2} u}{u^{2}+1} \ du + 2 \pi i \int_{0}^{\infty} \frac{\log u}{1+u^{2}} \ du - \pi^{2} \int_{0}^{\infty}\frac{1}{1+u^{2}} \ du \\  &= \int_{0}^{\infty} \frac{\log^{2} u}{u^{2}+1} \ du + 2 \pi i \int_{0}^{\infty} \frac{\log u}{1+u^{2}} \ du - \frac{\pi^{3}}{2} \end{align}$$
Therefore,
$$2 \int_{0}^{\infty} \frac{\log^{2} x}{1+x^{2}} \ dx + 2 \pi i \int_{0}^{\infty} \frac{\log x}{1+x^{2}} \ dx - \frac{\pi^{3}}{2} = - \frac{\pi^{3}}{4} $$
The final step is to equate the real parts and the imaginary parts on both sides of the equation.
