Proving that $\int_{0}^{\infty} \frac{\log(x) }{(1+x^2)^2}dx =- \frac{\pi}{4}$ using residues. I need to prove that $\displaystyle\int_{0}^{\infty} \frac{\log(x) }{(1+x^2)^2}\,dx = -\frac{\pi}{4}$ using the Residue theorem. I'm trying to solve using the function $f(z)=\dfrac{\log(z)}{(1+z^2)^2}$ (branch of $\log(z)$ with argument between $-\pi/2$ and $3\pi/2$)  and integrate over the curve $\gamma=[-R,-r] + \gamma_r +[r,R] + \gamma_R$, where $\gamma_r(t)=re^{-it}, t\in (0,\pi)$ and $\gamma_R(t)=Re^{it}, t\in (0,\pi)$. And I've already computed that $\operatorname{Res}(f,i)= -\pi/2 -\pi^2/4$. Also I think that limit when $R$ goes to $\infty$, the integral over $\gamma_R$ goes to $0$.
My big problem is the integral over $\gamma_r$.
 A: We work with
$$f(z) = \frac{\mathrm{log}(z)}{(z+i)^2(z-i)^2}$$
where $\log(z)$ is the principal branch with argument in $(-\pi,\pi].$
We use a semicircular contour indented at the origin wih radius $R$ in
the upper half  plane.  Let $\Gamma_0$ be the segment  on the positive
real axis  up to  $R$, $\Gamma_1$  the big  semicircle of  radius $R$,
$\Gamma_2$  the segment  on  the real  axis coming  in  from $-R$  and
finally $\Gamma_3$ the small semicircle of radius $\epsilon$ enclosing
the origin. We then have
$$\left(\int_{\Gamma_0}
+ \int_{\Gamma_1}+ \int_{\Gamma_2}+ \int_{\Gamma_3}\right) f(z) \; dz
= 2\pi i \times \mathrm{Res}_{z=i} f(z).$$
We have
$$\mathrm{Res}_{z=i} f(z)
= \left. \left(\frac{\mathrm{log}(z)}{(z+i)^2}\right)'\right|_{z=i}
= \left. \left(\frac{1}{z} \frac{1}{(z+i)^2}
- 2 \frac{\mathrm{log}(z)}{(z+i)^3}\right)\right|_{z=i}
\\ = \frac{1}{4i^3} - \frac{\pi i}{8i^3}
= \frac{\pi}{8} + \frac{i}{4}$$
Observe that in the limit
$$\int_{\Gamma_0}  f(z) \; dz =
\int_0^\infty \frac{\log(x)}{(x^2+1)^2} \; dx = J.$$
For $\Gamma_1$ we have by  ML estimate $\lim_{R\to\infty} \pi R \times
\sqrt{\log^2 R+ \pi^2} / (R-1)^4 = 0,$ so this vanishes.
Furthermore for $\Gamma_2$
$$\int_{\Gamma_2}  f(z) \; dz =
\int_{-\infty}^0 \frac{\log(|x|)+ \pi i}{(x^2+1)^2} \; dx =
\int_{-\infty}^0 \frac{\log(|x|)}{(x^2+1)^2} \; dx
+ \pi i \int_{-\infty}^0 \frac{1}{(x^2+1)^2} \; dx
\\ = \int_0^{\infty} \frac{\log(|x|)}{(x^2+1)^2} \; dx
+ \pi i \int_0^{\infty} \frac{1}{(x^2+1)^2} \; dx
= J + \pi i K.$$
For  $\Gamma_3$ we  again use  ML  and get  $\lim_{\epsilon\to 0}  \pi
\epsilon  \times \sqrt{\log^2  \epsilon  +\pi^2} =  0$,  so this  too
vanishes. We have shown that in the limit
$$2 J + \pi i K = 2\pi i\times
\left(\frac{\pi}{8} + \frac{i}{4}\right)
= - \frac{\pi}{2} + \frac{\pi^2}{4} i.$$
We know that $J$ and $K$ are real numbers, hence,
$$\bbox[5px,border:2px solid #00A000]{
\int_0^\infty \frac{\log(x)}{(x^2+1)^2} \; dx = - \frac{\pi}{4}
\quad\text{and}\quad
\int_0^\infty \frac{1}{(x^2+1)^2} \; dx = \frac{\pi}{4}.}$$
A: Your parametrization for $\gamma_r(t)$ doesn't do what you think it does. It goes below the singularity (thereby crossing the branch cut it shouldn't) instead of going backwards. I'll use the correct version that doesn't include the singularity at $0$ by letting 
$$\gamma_r(t) = re^{it} \hspace{20 pt} t\in (0,\pi)$$
but just have the integral go backwards. Using the branch that you have, the integral over $\gamma_r$ can be shown to be bounded by the following:
$$\Biggr| \int_\pi^0 \frac{\log r + it}{(1+r^2e^{i2t})^2}\left(ire^{it}dt\right)\Biggr| \leq (r\log r + \pi r)\int_0^\pi \frac{dt}{|1+r^2e^{i2t}|^2} \leq \frac{\pi r\log r + \pi^2 r}{(1-r^2)^2} $$
by triangle inequality. The limit goes to $0$ because $r$ dominates $\log r$. Thus the integral over $\gamma_r$ vanishes.
