TITLE: Calculating contour integral with keyhole contour
QUESTION [7 upvotes]: Evaluate the integral $\int_0^{\infty}\frac{\log(x)}{(x+a)(x+b)}dx$ with $a,b>0, a\neq b$ by using the keyhole contour.

My attempt-
I drew the keyhole contour (obviously it's supposed to say $-a,-b$ on the left side of the $x$ axis):

And we have the following as we let $\varepsilon\to 0$ and $R\to\infty$:
$$\int_{\Gamma}f(z)dz=2\pi i(Res(f,-a)+Res(f,-b))$$
$$\int_{\gamma_{R}}\frac{\log(z)}{(z+a)(z+b)}dz\to 0$$
$$\int_{\gamma_{\varepsilon}}\frac{\log(z)}{(z+a)(z+b)}dz\to 0$$
$$\int_{\gamma_{1}}\frac{\log(z)}{(z+a)(z+b)}dz\underset{\underset{\varepsilon\to0}{R\to\infty}}{\to}\int_{0}^{\infty}\frac{\log(x)}{(x+a)(x+b)}dx$$
The only thing I'm having trouble calculating is:
$$\int_{\gamma_{2}}\frac{\log(z)}{(z+a)(z+b)}dz$$ as $\varepsilon\to 0$ and $R\to\infty$. I assume it's: $$\int_{\gamma_{2}}\frac{\log(z)}{(z+a)(z+b)}dz=-\int_{0}^{\infty}\frac{\log(x)+2\pi i}{(x+a)(x+b)}dz$$ and if I denote $I=\int_{0}^{\infty}\frac{\log(x)}{(x+a)(x+b)}dx$ then $$\int_{\gamma_{2}}\frac{\log(z)}{(z+a)(z+b)}dx=I+2\pi i\frac{\ln(a)-\ln(b)}{a-b}$$ and when summing everything $I$ cancels. What am I doing wrong here?

REPLY [3 votes]: Actually you do not need Complex Analysis for this: $\frac{1}{(x+a)(x+b)}=\frac{1}{b-a}\left(\frac{1}{x+a}-\frac{1}{x+b}\right)$ and
$$\begin{eqnarray*}\int_{0}^{M}\frac{\log x}{x+c}\,dx&\stackrel{x\mapsto cz}{=}& \int_{0}^{M/c}\frac{\log(c)+\log(z)}{z+1}\,dz=\log(c)\log(1+M/c)+\int_{0}^{M/c}\frac{\log z}{z+1}\,dz\\&\stackrel{z\mapsto 1/u}{=}&\log(c)\log(1+M/c)-\int_{c/M}^{+\infty}\frac{\log u}{u(u+1)}\\&\stackrel{u\mapsto v/M}{=}&\log(c)\log(1+M/c)-\int_{c}^{+\infty}\frac{\log(v)-\log(M)}{v(v/M+1)}\,dv\\&=&\log(Mc)\log(1+M/c)-\int_{c}^{+\infty}\frac{\log v}{v(v/M+1)}\,dv\tag{1}\end{eqnarray*}$$
from which it follows that
$$\int_{0}^{+\infty}\frac{\log x}{(x+a)(x+b)}\,dx =\\= \frac{1}{b-a}\lim_{M\to +\infty}\left(\log(Ma)\log(1+M/a)-\log(Mb)\log(1+M/b)-\int_{a}^{b}\frac{\log v}{v(v/M+1)}\,dv\right).\tag{2}$$
By the dominated convergence theorem the integral term inside the parenthesis converges to $-\frac{\log^2(b)-\log^2(a)}{2}$ while it is simple to check (for instance, through Lagrange's theorem) that
$$\lim_{M\to +\infty}\left(\log(Ma)\log(1+M/a)-\log(Mb)\log(1+M/b)\right)=\log^2(b)-\log^2(a),\tag{3}$$
leading to
$$ \int_{0}^{+\infty}\frac{\log(x)}{(x+a)(x+b)}\,dx = \frac{\log^2(b)-\log^2(a)}{2(b-a)}\tag{3} $$
as wanted. An alternative is to use Feynman's trick.