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
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
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