<s>[INST] The value of the definite integral The value of the definite integral $\displaystyle\int\limits_0^\infty \frac{\ln x}{x^2+4} \, dx$ is
(A) $\dfrac{\pi \ln3}{2}$   (B) $\dfrac{\pi \ln2}{3}$  (C) $\dfrac{\pi \ln2}{4}$  (D) $\dfrac{\pi \ln4}{3}$
I tried using integration by parts,
\begin{align}
& \int_0^\infty \frac{\ln x}{x^2+4}dx = \ln x\int_0^\infty \frac{1}{x^2+4}dx-\int_0^\infty \left(\frac{d}{dx}\ln x\int_0^\infty \frac{1}{x^2+4}\right) \, dx \\[10pt]
= {} & \left[\ln x \frac{1}{2}\tan^{-1}\frac{x}{2}\right]-\int_0^\infty \frac{1}{x}\frac{1}{2}\tan^{-1}\frac{x}{2} \, dx
\end{align}
I could not move ahead. Can someone help me to get final answer?
 [/INST] Using the substitution $\displaystyle \theta=\frac{1}{2}\arctan\left(\frac{x}{2}\right)$ so $\displaystyle \text{d}\theta=\frac{1}{x^2+4} \text{d}x$ and $\displaystyle x=2\tan(2\theta)$ we get $$\int_{0}^{\infty}\frac{\ln(x)}{x^2+4}\text{d}x=\int_{0}^{\frac{\pi}{4}}\ln\left(2\tan(2\theta)\right)\text{d}\theta= \\ =\int_{0}^{\frac{\pi}{4}}\ln(2)\text{d}\theta+\int_{0}^{\frac{\pi}{4}}\ln\sin(2\theta)\text{d}\theta-\int_{0}^{\frac{\pi}{4}}\ln\cos(2\theta)\text{d}\theta $$
Last two integrals cancel each other, so we get $$\int_{0}^{\infty}\frac{\ln(x)}{x^2+4}\text{d}x=\int_{0}^{\frac{\pi}{4}}\ln(2)\text{d}\theta=\frac{\pi \ln(2)}{4}$$

Of course, we can generalize and compute $\displaystyle \int_{0}^{\infty}\frac{\ln(x)}{x^2+k^2}\text{d}x$.
Using the substitution $\displaystyle \theta=\frac{1}{k}\arctan\left(\frac{x}{k}\right)$ we get $\displaystyle \text{d}\theta=\frac{1}{x^2+k^2}\text{d}x \ , \ x=k\tan(k\theta)$, hence $$\int_{0}^{\infty}\frac{\ln(x)}{x^2+k^2}\text{d}x=\int_{0}^{\Large \frac{\pi}{2k}}\ln(k\tan(k\theta))\text{d}\theta= \\ =\int_{0}^{\Large \frac{\pi}{2k}}\ln(k)\text{d}\theta+\int_{0}^{\Large \frac{\pi}{2k}}\ln(\sin(k\theta))\text{d}\theta-\int_{0}^{\Large \frac{\pi}{2k}}\ln(\cos(k\theta))\text{d}\theta$$
Now, we prove that $\displaystyle I=\int_{0}^{\Large \frac{\pi}{2k}}\ln(\sin(k\theta))\text{d}\theta-\int_{0}^{\Large \frac{\pi}{2k}}\ln(\cos(k\theta))\text{d}\theta=0$.
For the first integral we use the substitution $\displaystyle u=\frac{\pi}{2}-k\theta$ and for the second integral we use the substitution $\displaystyle u=k\theta$, hence $$I=-\frac{1}{k}\int_{\Large \frac{\pi}{2}}^{0}\ln(\cos(u))\text{d}u-\frac{1}{k}\int_{0}^{\Large \frac{\pi}{2}}\ln(\cos(u))\text{du}=0$$
Eventually, $\displaystyle \boxed{\color{#2E2EFE}{\int_{0}^{\infty}\frac{\ln(x)}{x^2+k^2}\text{d}x=\int_{0}^{\Large \frac{\pi}{2k}}\ln(k)\text{d}\theta =\frac{\pi}{2k}\ln(k)}}$.
</s>