I've been going crazy with this complex integral I have to estimate with the Residues Theorem. I'm obviously missing a sign or something else, but I fear I may be committing a conceptual mistake.
$$\int_{0}^{\infty} \frac{\log x}{x^2-1} \mathrm{d}x$$
I choose to solve this integral by computing the following complex integral:
\begin{align*} \int_{\gamma} \frac{\log^2 z}{z^2-1}dz &= \lim_{\epsilon \to 0} \bigg{[} \int_{0}^{R} dx \frac{\log^2 (x+i\epsilon)}{(x+i\epsilon)^2-1}+\int_{R}^{0} dx \frac{\log^2 (x-i\epsilon)}{(x-i\epsilon)^2-1} \\ &+\int_{2\pi}^{0}d\theta i \epsilon e^{i\theta} \frac{\log^2 (\epsilon e^{i\theta})}{(\epsilon e^{i\theta})^2-1} +\int_{2\pi}^{0}d\theta i \epsilon e^{i\theta} \frac{\log^2 (1+\epsilon e^{i\theta})}{(1+\epsilon e^{i\theta})^2-1} \bigg{]} + \int_{\tilde \gamma}dz \frac{\log^2 z}{z^2-1} \end{align*}
Where $\gamma$ is the "keyhole" path, and $\tilde\gamma$ is the circle centered in $z=0$ with $R$ radius. If $R\rightarrow\infty$, then:
\begin{align*} &=\int_{0}^{\infty} dz \frac{\log^2 (x)}{x^2-1}-\int_{0}^{\infty} dx \frac{(\log (x)+2\pi i)^2}{x^2-1} \\ &=-4\pi i \int_{0}^{\infty}dx\frac{\log (x)}{x^2-1}+ 4 \pi^2 \int_{0}^{\infty} dx \frac{1}{x^2-1}=-4\pi i \int_{0}^{\infty}dx\frac{\log (x)}{x^2-1} \end{align*}
since $$\int_{0}^{\infty}\frac{1}{x^2-1}\mathrm{d}x = 0.$$
I can estimate the complex integral with the Residues theorem:
$$\int_{\gamma} \frac{\log^2 z}{z^2-1}dz=2\pi i \mathrm{Res}[f(z), -1]=i \pi^3$$
and this means that:
$$\int_{0}^{\infty} \frac{\log (x)}{x^2-1}\mathrm{d}x=-\frac{\pi^2}{4}$$
which is wrong, since the correct result should be $\frac{\pi^2}{4}$.
Is there something wrong with my procedure?