<s>[INST] How to solve this integral: $\int_0^\infty{\frac{ln x}{x^2+2x+4}}\cdot dx$ I have been trying to solve this integral:- $$\int_0^\infty{\frac{\ln x}{x^2+2x+4}}\cdot dx$$ But I have been unsuccessful so far. I have tried integration by parts ( taking $1/(x^2+2x+4)$ as the second function does not work because it ends of as tan-inverse function which is more compicated to integrate.)
taking $\ln x$ as the second function was interesting, I ended up in this dead end:-
$$\begin{align} I&=\int_0^\infty{\frac{\ln x}{x^2+2x+4}}\cdot dx \\ &= \left[ {\frac{x\ln x -x}{x^2+2x+4}}\right]_0^\infty + \int_0^\infty \frac{2(x+1)(x\ln x-x)}{(x^2+2x+4)^2}\cdot dx \\&= 2\int_0^\infty \frac{(x^2+2x+4-(x+4))(\ln x-1)}{(x^2+2x+4)^2}\cdot dx \\ &= 2\int_0^\infty\frac{\ln x}{x^2+2x+4}\cdot dx - 2\int_0^\infty\frac{1}{x^2+2x+4}\cdot dx -2\int_0^\infty \frac{(x+4)(\ln x-1)}{(x^2+2x+4)^2}\cdot dx \\&= 2I - \left[\frac{1}{\sqrt{3}} \tan^{-1}{\frac{x+1}{\sqrt{3}}} \right]_0^\infty - 2\int_0^\infty \frac{(x+4)(\ln x-1)}{(x^2+2x+4)^2}\cdot dx \end{align}$$
the function in the second step limits to $0$ so I didn't mention it in the third step. Now I have quartic polynomial at the bottom and don't know how to proceed. I have also tried trigonometric substitution ($ x=\tan\theta$)
If possible please try to end this process, I am a high school student so please keep that in mind if you show another method :)
 [/INST] The Path
To evaluate
$$\newcommand{\Res}{\operatorname*{Res}}
\begin{align}
\int_0^\infty{\frac{\log(x)}{x^2+2x+4}}\,\mathrm{d}x\tag1
\end{align}
$$
we will evaluate
$$
\int_\gamma{\frac{\log(x)^2}{x^2+2x+4}}\,\mathrm{d}x\tag2
$$
where
$$
\begin{align}
\gamma
&=\left[\epsilon+i\epsilon^2,R+i\epsilon^2\right]\cup\sqrt{R^2+\epsilon^4}e^{i\left[\arctan\left(\frac{\epsilon^2}R\right),2\pi-\arctan\left(\frac{\epsilon^2}R\right)\right]}\\
&\,\cup\left[R-i\epsilon^2,\epsilon-i\epsilon^2\right]\cup\sqrt{\epsilon^2+\epsilon^4}e^{i[2\pi-\arctan(\epsilon),\arctan(\epsilon)]}
\end{align}\tag3
$$
as $\epsilon\to0$ and $R\to\infty$.


The Integral Along The Pieces
The integral along both curved pieces tends to $0$.
The integral along the upper line tends to
$$
\int_0^\infty\frac{\log(x)^2}{x^2+2x+4}\,\mathrm{d}x\tag4
$$
The integral along the lower line tends to
$$
-\int_0^\infty\frac{\log(x)^2+4\pi i\log(x)-4\pi^2}{x^2+2x+4}\,\mathrm{d}x\tag5
$$
Thus, the integral in $(2)$ is equal to the sum of these four parts:
$$
\int_0^\infty\frac{4\pi^2-4\pi i\log(x)}{x^2+2x+4}\,\mathrm{d}x\tag6
$$
The imaginary part of which is the integral in question.

The Residues
Since
$$
\frac1{x^2+2x+4}=\frac1{2i\sqrt3}\left(\frac1{x+1-i\sqrt3}-\frac1{x+1+i\sqrt3}\right)\tag7
$$
we have
$$
\Res_{z=-1+i\sqrt3}\left(\frac1{z^2+2z+4}\right)=\frac1{2i\sqrt3}\tag8
$$
and
$$
\Res_{z=-1-i\sqrt3}\left(\frac1{z^2+2z+4}\right)=-\frac1{2i\sqrt3}\tag9
$$
Thus, the integral in $(6)$ is the $2\pi i$ times the sum of the residues inside $\gamma$, which is
$$
\begin{align}
&\frac\pi{\sqrt3}\log\left(-1+i\sqrt3\right)^2-\frac\pi{\sqrt3}\log\left(-1-i\sqrt3\right)^2\\
&=\frac\pi{\sqrt3}\left(\log(2)+i\frac{2\pi}3\right)^2-\frac\pi{\sqrt3}\left(\log(2)+i\frac{4\pi}3\right)^2\\
&=\frac{4\pi^3-4\pi^2i\log(2)}{3\sqrt{3}}\tag{10}
\end{align}
$$

The Results
$(10)$ and $(6)$ say that
$$
\int_0^\infty\frac1{x^2+2x+4}\,\mathrm{d}x=\frac\pi{3\sqrt3}\tag{11}
$$
$$
\int_0^\infty\frac{\log(x)}{x^2+2x+4}\,\mathrm{d}x=\frac{\pi\log(2)}{3\sqrt3}\tag{12}
$$
</s>