Evaluating the complex integral $\int_{0}^{\infty} \frac {\sin (\ln x) dx }{x^2 + 4} $ 
I want to evaluate following integral:
$\int_{0}^{\infty} \frac {\sin (\ln x) dx }{x^2 + 4}  $



*

*Obviously $x$ $ \gt $ $0$ and the function we want to integrate isn't even nor odd. And I need to avoid $0$.

*We got two first order poles at $+2i$ and $-2i$

*$f(z) = \frac {\sin (\ln z)  }{z^2 + 4} = \Im \{\frac {e^{(i\ln z)}  }{z^2 + 4} \} $ and we are dealing with a complex logarithm

*The residue of the function above for $+2i$ is equal to $res(f, +2i) =\frac {e^{(i Ln 2)}}{4i}$ and I am considering calculating the residue for $-2i$ (it would just switch a sign)
The solution is according to textbook: $\frac {\pi \sin (Ln(2)}{4 \cosh(\pi /2)}$
My questions: 
1) How to deal with the integral from $0$ to $\infty$, not from $- \infty$ to $\infty$ in this case. I was used to deal with even functions where it was obvious.
2) I have no clue about the integration path (a semi-circle with branch cuts?)
3) Why that $cosh$ in that solution?
This type of the complex integral is very new to me and I would appreciate any help!
 A: Use the substitution
$$x = 2e^t$$
for instance. This gives:
$$
\begin{aligned}
\int_{0}^{\infty} \frac {\sin \ln x }{x^2 + 4}\; dx 
&=
\int_{-\infty}^{\infty} 
\frac {\sin (\ln 2 + t) }{4e^{2t} + 4}\; 2e^t\; dt
\\
&=
\frac 12
\int_{-\infty}^{\infty} 
\frac {\sin \ln 2\cos t+\cos \ln 2\sin t }{e^{t} + e^{-t}}\;  dt
\\
&=
\frac 12
\int_{-\infty}^{\infty} 
\frac {\sin \ln 2\cos t +\text{odd function}}{e^{t} + e^{-t}}\;  dt
\\
&=
\frac 12\sin\ln 2
\int_{-\infty}^{\infty} 
\frac {\cos t}{e^{t} + e^{-t}}\;  dt
\ .
\end{aligned}
$$
This is a better situation suited for an application of the residue theorem.
The residues of the function
$$
f(z)=\frac{\cos z}{e^z + e^{-z}}
$$
in the poles
$$
k\cdot \frac {i\pi} 2\ ,\qquad\text{ $k$ odd, }k=2n+1\ ,
$$
are correspondingly
$$
-\frac  i2(-1)^n\cosh \frac {k\pi}2\ .
$$
Now we need to find the "good contour". The known result already tells us that $i\pi/2$ counts, but the "next" residue, $3i\pi/2$ "should not count". OK, let us then consider the rectangular contour with the corners
$$
-R\ , \  +R\ , \  +R+i\pi\ , \  -R+i\pi\ .
$$
Then for $z\in[-R,R]$
$$
\Re f(z+i\pi)
=
\Re \frac{\cos (z+i\pi)}{e^{z+i\pi} + e^{-z-i\pi}}
=
\Re \frac{\cos z\cos(i\pi)-\sin z\sin(i\pi)}{-(e^{z} + e^{-z})}
=
\Re \frac{\cos z\cosh \pi}{-(e^{z} + e^{-z})}
=-
\cosh \pi f(z)\ .
$$
Applying the residue theorem on the rectangle:
$$
\begin{aligned}
2\pi\,i\cdot 
\left(-\frac{1}{2} i \, \cosh\left(\frac\pi{2}\right)\right)
&=
\lim_{R\to \infty}\int_{-R}^R f(z)\; dz
+
\lim_{R\to \infty}\int_{R+i\pi}^{-R+i\pi} f(z)\; dz
\\
&=
(1+\cosh\pi)\lim_{R\to \infty}\int_{-R}^R f(z)\; dz
\\
&=
2\cosh^2\left(\frac \pi2\right)\cdot\int_{-\infty}^\infty f(z)\; dz\ .
\end{aligned}
$$
It remains to put all together in one line:
$$
\int_{0}^{\infty} \frac {\sin \ln x }{x^2 + 4}\; dx 
=
\frac 12\sin\ln2\int_{\Bbb R}f
=
\frac 12\sin\ln2\cdot \frac \pi{2\cosh(\pi/2)}\ .
$$
$\square$
A: Consider the function $f(z) = \frac{e^{i\log z}}{4+z^2}$ where the branch of the logarithm corresponds to $-\pi < \arg z \leq \pi$. We will integrate $f(z)$ around the following "key-hole" contour:

$C_R$ is a circle of radius $R$ and $C_{\epsilon}$ is a half-circle of radius $\epsilon$. Both of them are centered at $0$. 
As $R\to\infty$ and $\epsilon\to 0^+$, the integrals around $C_R$ and $C_\epsilon$ tend to $0$. So, we are only left with the integrals above and below the branch cut. 
While calculating the residues, one must be careful about the branch of the logarithm.
\begin{align*}
\mathop{\text{Res}}\limits_{z=2i} \; f(z)&= \lim_{z\to 2i} (z-2i) \frac{e^{i\log z}}{z^2+4} \\
&= \frac{e^{i\log(2i)}}{4i} \\
&= \frac{e^{i\ln 2- \arg (i)}}{4i}\\
&= \frac{e^{i\ln 2 -\frac{\pi}{2}}}{4i}
\end{align*}
Similarly,
\begin{align*}
\mathop{\text{Res}}\limits_{z=-2i} \; f(z)=-\frac{e^{i\ln 2 -\arg(-i)}}{4i} =-\frac{e^{i\ln 2 +\frac{\pi}{2}}}{4i}
\end{align*}
Therefore, using the Residue Theorem,
\begin{align*}
\int_{-\infty}^0 \frac{e^{i(\ln|x|+i\pi)}}{4+x^2}dx +\int_0^{-\infty} \frac{e^{i(\ln|x|-i\pi)}}{4+x^2}dx &= 2\pi i \left(\mathop{\text{Res}}\limits_{z=2i} \; f(z) + \mathop{\text{Res}}\limits_{z=-2i} \; f(z)\right) \\
\Rightarrow e^{-\pi}\int_0^\infty \frac{e^{i\ln x}}{4+x^2}dx - e^{\pi}\int_0^\infty \frac{e^{i\ln x}}{4+x^2}dx &= 2\pi i \left( \frac{e^{i\ln 2}}{4i}e^{-\frac{\pi}{2}}- \frac{e^{i\ln 2}}{4i}e^{\frac{\pi}{2}}\right) \\
\Rightarrow -2\sinh(\pi) \int_0^\infty \frac{e^{i\ln x}}{4+x^2}dx  &= -\sinh\left(\frac{\pi}{2}\right) \pi e^{i\ln 2} \\
\Rightarrow \int_0^\infty \frac{e^{i\ln x}}{4+x^2}dx &= \frac{\pi e^{i\ln 2}}{4\cosh\left(\frac{\pi}{2}\right)}
\end{align*}
Now, separate the imaginary parts to get the answer.
A: $$
\begin{align}
\int_0^\infty\frac{\sin(\log(x))\,\mathrm{d}x}{x^2+4}
&=\frac14\int_{-\infty}^\infty\frac{\sin(x+\log(2))\,\mathrm{d}x}{\cosh(x)}\tag1\\
&=\frac{\sin(\log(2)}4\int_{-\infty}^\infty\frac{\cos(x)\,\mathrm{d}x}{\cosh(x)}\tag2\\[3pt]
&=\frac\pi4\sin(\log(2))\,\mathrm{sech}\!\left(\frac\pi2\right)\tag3
\end{align}
$$
Explanation:
$(1)$: substitute $x\mapsto2e^x$
$(2)$: the even part of $\sin(x+\log(2))$ is $\sin(\log(2))\cos(x)$
$(3)$: double the result of this answer
A: An alternative approach. By Euler's Beta function and the reflection formula for the $\Gamma$ function we have
$$ \int_{0}^{+\infty}\frac{x^a}{x^2+4}\,dx = \frac{\pi}{2^{2-\alpha}\cos\frac{\pi\alpha}{2}}\tag{1}$$
for any $\alpha$ such that $\text{Re}(\alpha)\in(-1,1)$. By considering $\alpha=i$ we get
$$ \int_{0}^{+\infty}\frac{\cos\log(x)+i\sin\log(x)}{x^2+4}\,dx=\frac{\pi}{4\cosh\frac{\pi}{2}}\left[\cos\log 2+i\sin\log 2\right]\tag{2} $$
so
$$ \int_{0}^{+\infty}\frac{\sin\log(x)}{x^2+4}\,dx=\frac{\pi\sin\log 2}{4\cosh\frac{\pi}{2}}.\tag{3} $$
