Approaching a contour integral with singularities on each axis How do I solve an integral like this using complex methods? 
$$ \int_{0}^{\infty} \frac{\ln(x)}{\left(x^2 + 2\right)\left(x^2 + 1\right)}dx.$$
I tried using two semi circles in the upper half plane but the singularities on the real axis are troublesome for me and I'm not sure how to approach the problem 
 A: You can indeed use a "quasi semicircle" as an integration contour
Let's define the complex valued function 
$$
f(z)=\frac{\log(z)}{(z^2+2)(z^2+1)}
$$
we choose the branch cut of log to lie on negative real axis.
We integrate $f(z)$ along a contour which consists of a line segement just above the negative real axis $l_-$, the real axis $l_+$ and a large semicircle in the upper half plane $C$. A sketch of this contour can be found at the end of the answer (branch cut in red).
Then (residue theorem)
$$
\oint f(z)dz=\underbrace{\int_C f(z)dz}_{\rightarrow0}+\underbrace{\int_{l_+} f(z)dz}_{I}+\int_{l_-}f(z)dz=2\pi i\sum_{i=1,2}\text{Res}(f(z),z=z_i)
$$
but $$\int_{l_-}f(z)dz=\int_{-\infty}^0\frac{\log(|x|)+i\pi}{(x^2+2)(x^2+1)}=\int_0^{\infty}\frac{\log(x)+i\pi}{(x^2+2)(x^2+1)}=I+i\pi\int_0^{\infty}\frac{1}{(x^2+2)(x^2+1)}$$ 
which leads us to

$$
2I=-i\pi\underbrace{\int_0^{\infty}\frac{1}{(x^2+2)(x^2+1)}}_J+2\pi i\sum_{i=1,2}\text{Res}(f(z),z=z_i)
$$

We now need (the integral is standard)
$$
J=\frac{\pi}{2\sqrt{2}}-\frac{\pi}{2}\\
\text{Res}(f(z),z=i)=\frac{\pi}{4}\\
\text{Res}(f(z),z=i\sqrt{2})=-\frac{\pi}{4\sqrt{2}}+i\frac{\log(2)}{4\sqrt{2}}
$$
putting everything in the highlighted formula above this gives

$$
2I=-\pi\frac{\log(2)}{2\sqrt{2}}
$$



A: It is enough to compute:
$$ \color{purple}{I}=I_1-I_2=\int_{0}^{+\infty}\frac{\log(x)}{1+x^2}\,dx -\int_{0}^{+\infty}\frac{\log(x)}{2+x^2}\,dx $$
where the substitution $x=t\sqrt{2}$ gives
$$ I_2 = \frac{1}{\sqrt{2}}\int_{0}^{+\infty}\frac{\log(t)+\log\sqrt{2}}{1+t^2}\,dt$$
and

$$ I = \left(1-\frac{1}{\sqrt{2}}\right) \color{red}{\int_{0}^{+\infty}\frac{\log x}{1+x^2}\,dx} -\frac{\log 2}{4\sqrt{2}}\color{blue}{\int_{-\infty}^{+\infty}\frac{dx}{1+x^2}}.$$

Now $\int_{-\infty}^{+\infty}\frac{dx}{1+x^2}=\color{blue}{\pi}$ by the residue theorem and $I_1=\color{red}{0}$ by a simple symmetry trick, i.e.the substitution $x=\frac{1}{z}$. It follows that $I=\color{purple}{\large-\frac{\pi\log 2}{4\sqrt{2}}}.$
