The integral I'd like to evaluate is $\int_0^\infty \frac{\log^2 x \, dx}{(1+x)^2}$. I consider the function $f(z) = \frac{\text{Log}^2 z}{(1+z)^2}$, which has a pole of order 2 at $z=-1$ and has a branch point at $z=0$. I set up the integral $\oint_C f(z) dz$ along the contour $C = C_1 + C_2 + C_3 + C_4 + C_5 + C_6$, which consists of $C_1$ going just above the branch cut from $0$ to infinity, $C_2$, which is a big half-circle, $C_3$, which is a piece along the real axis from infinity to a point infinitesimally close to $z=-1$, $C_4$, which is a small half-circle going around $z=-1$ clockwise, $C_5$, which is another small piece on the real axis, and, finally, $C_6$, which is a quarter-circle around the origin to close the contour.
Now, I take the branch with $\text{Log}(z) = \log(r) + i \theta$, $0 \le\theta<2\pi$. Then the piece along $C_1$ is the integral $I$ I want to calculate. The pieces along $C_2$ and $C_6$ are zero when we take appropriate limits, but I'm not sure what to do with all the other pieces, since we can't really (can we?) write them in a way "$\text{something} \cdot I$", because of the singularity at $z=-1$. I know what I would do in the case of $1+z^2$ in the denominator, but not in this one. Suggestions?
I would consider the integral
$$\oint_C dz \frac{\log^3{z}}{(1+z)^2} $$
where $C$ is a keyhole contour about the real axis of radius $R$. Then as $R \to \infty$ the integral is equal to
$$-i 6 \pi \int_0^{\infty} dx \frac{\log^2{x}}{(1+x)^2} + 12 \pi^2 \int_0^{\infty} dx \frac{\log{x}}{(1+x)^2} +i 8 \pi^3 \int_0^{\infty} dx \frac{1}{(1+x)^2} = i 2 \pi \operatorname*{Res}_{z=e^{i \pi}} \frac{\log^3{z}}{(1+z)^2}$$
Note that the definition of the keyhole contour implies that the pole at $z=-1$ is necessarily represented as $z=e^{i \pi}$, as $\arg{z} \in [0,2 \pi]$.
To evaluate the other integrals we consider similar contour integrals:
$$\oint_C dz \frac{\log^2{z}}{(1+z)^2} = -i 4 \pi \int_0^{\infty} dx \frac{\log{x}}{(1+x)^2} + 4 \pi^2 \int_0^{\infty} dx \frac{1}{(1+x)^2} = i 2 \pi \operatorname*{Res}_{z=e^{i \pi}} \frac{\log^2{z}}{(1+z)^2}$$
$$\oint_C dz \frac{\log{z}}{(1+z)^2} = -i 2 \pi \int_0^{\infty} dx \frac{1}{(1+x)^2} = i 2 \pi \operatorname*{Res}_{z=e^{i \pi}} \frac{\log{z}}{(1+z)^2}$$
Back substituting the other integral expressions into the first one, we find that
$$-i 6 \pi \int_0^{\infty} dx \frac{\log^2{x}}{(1+x)^2} + 12 \pi^2 \left [ i \pi \operatorname*{Res}_{z=e^{i \pi}} \frac{\log{z}}{(1+z)^2}-\frac12 \operatorname*{Res}_{z=e^{i \pi}} \frac{\log^2{z}}{(1+z)^2}\right ] \\ -i 8 \pi^3 \operatorname*{Res}_{z=e^{i \pi}} \frac{\log{z}}{(1+z)^2} = i 2 \pi \operatorname*{Res}_{z=e^{i \pi}} \frac{\log^3{z}}{(1+z)^2} $$
or
$$\begin{align}\int_0^{\infty} dx \frac{\log^2{x}}{(1+x)^2} &= \operatorname*{Res}_{z=e^{i \pi}} \frac{(2 \pi^2/3 )\log{z}+ i \pi \log^2{z} - (1/3) \log^3{z}}{(1+z)^2}\\ &= \left (\frac{2 \pi^2}{3} \right )\frac1{e^{i \pi}} + (i \pi) 2 \frac{i \pi}{e^{i \pi}} -\frac13 \frac{3 (i \pi)^2}{e^{i \pi}}\end{align}$$
Thus,