Integral with Euler-Mascheroni constant I want to solve the following integral
$$\int_0^\infty \frac{\sin{x}\ln{x}}{x}dx$$
To make things worse (or better?), I parameterize the sine function to $e^{-ax}$.
\begin{align*}
I(a)&=\int_{0}^\infty\frac{e^{-ax}\ln{x}}{x}dx\\
\frac{dI}{da}&=-\int_{0}^\infty e^{-ax}\ln{x}dx\\
&=-\frac{1}{a}\int_0^\infty e^{-t}+\frac{\ln{a}}{a}\int_0^{\infty}e^{-t}dt
\end{align*}
knowing th value of the individual integrals, I can conclude(?)
$$\int_0^{\infty}\frac{e^{-ax}\ln{x}}{x}dx=\gamma\ln{a}+\frac{\ln^2{a}}{2}$$
solving for $a=i,\ln{i}=\frac{i\pi}{2}$ and considering only the imaginary value,
$$\int_0^\infty\frac{\sin{x}\ln{x}}{x}dx=-\frac{\gamma\pi}{2}$$
which by any chance correct, even though the real part does not. Can someone please tell me the mistakes?
 A: As already mentioned by TheSimpliFire you cannot simply change from real to complex variables without any changes within your solution. I will present you a solution which does not rely on complex analysis at all.

Recently reading this post dealing with related integrals I have finally found a way to evaluate your integral. However, the crucial part we are in need of is precisely the Mellin Transform of the sine function which is given by

$$\mathcal M_s\{\sin(x)\}~=~\int_0^\infty x^{s-1}\sin(x)\mathrm dx~=~\Gamma(s)\sin\left(\frac{\pi s}2\right)\tag1$$

Here $\Gamma(z)$ denotes the Gamma Function. There are different possible ways to show this relation, for myself I prefer using Ramanujan's Master Theorem as it is done here for example $($just substitute $s$ by $-s$$)$, but I will leave this out for now hence it is not of our concern. Note that we can use a variation of Feynman's Trick, i.e. Differentation under the Integral Sign. Before applying this technique we may rewrite the RHS of $(1)$ in the following way
$$\Gamma(s)\sin\left(\frac{\pi s}2\right)=\Gamma(s)\sin\left(\frac{\pi s}2\right)\frac{2\cos\left(\frac{\pi s}2\right)}{2\cos\left(\frac{\pi s}2\right)}=\frac1{{2\cos\left(\frac{\pi s}2\right)}}\Gamma(s)\sin(\pi s)=\frac\pi2\frac1{\Gamma(1-s)\cos\left(\frac{\pi s}2\right)}$$
Here we used Euler's Reflection Formula. Even though the new form seems to be more complicated in the context of taking derivatives it actually prevents us from running into indefinite expressions which are harder to deal with. Anyway, differentiating w.r.t. $s$ leads us to 
\begin{align*}
\frac{\mathrm d}{\mathrm ds}\int_0^\infty x^{s-1}\sin(x)\mathrm dx&=\frac{\mathrm d}{\mathrm ds}\frac\pi2\frac1{\Gamma(1-s)\cos\left(\frac{\pi s}2\right)}\\
\int_0^\infty \frac{\partial}{\partial s}x^{s-1}\sin(x)\mathrm dx&=\frac\pi2\frac{\mathrm d}{\mathrm ds}\frac1{\Gamma(1-s)\cos\left(\frac{\pi s}2\right)}\\
\int_0^\infty x^{s-1}\log(x)\sin(x)\mathrm dx&=\frac\pi2\left[\frac1{\cos\left(\frac{\pi s}2\right)}\frac{-(-1)\Gamma'(1-s)}{\Gamma^2(1-s)}+\frac1{\Gamma(1-s)}\frac{-\frac\pi2\sin\left(\frac{\pi s}2\right)}{\cos^2\left(\frac{\pi s}2\right)}\right]\\
\int_0^\infty x^{s-1}\log(x)\sin(x)\mathrm dx&=\frac\pi2\left[\frac1{\cos\left(\frac{\pi s}2\right)}\frac{\psi^{(0)}(1-s)}{\Gamma(1-s)}-\frac\pi2\frac1{\Gamma(1-s)}\frac{\sin\left(\frac{\pi s}2\right)}{\cos^2\left(\frac{\pi s}2\right)}\right]
\end{align*}
Now we are basically done. Hence every occuring term is defined at $s=0$ we can simply plug in this value. Utilizing that the Digamma Function $\psi^{(0)}(z)$ is closely related to the Euler-Mascheroni Constant we can deduce that
$$\int_0^\infty x^{0-1}\log(x)\sin(x)\mathrm dx=\frac\pi2\left[\underbrace{\frac1{\cos\left(\frac{\pi\cdot0}2\right)}\frac{\psi^{(0)}(1-0)}{\Gamma(1-0)}}_{=-\gamma}-\underbrace{\frac\pi2\frac1{\Gamma(1-0)}\frac{\sin\left(\frac{\pi\cdot0}2\right)}{\cos^2\left(\frac{\pi\cdot0}2\right)}}_{=0}\right]$$

$$\therefore~\int_0^\infty \frac{\log(x)\sin(x)}x\mathrm dx~=~-\frac{\gamma\pi}2$$

A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
$\ds{\bbox[5px,#ffd]{\int_{0}^{\infty}{\sin\pars{x}\ln\pars{x} \over x}\,\dd x = -\,{\pi \over 2}\,\gamma} \approx -0.9067\ {\Large ?}}$.

A known result:
$$
\left.\int_{0}^{\infty}x^{\nu - 1}\sin\pars{x}\,\dd x
\,\right\vert_{\ \verts{\Re\pars{\nu}}\ <\ 1} =
\sin\pars{\pi\nu \over 2}\Gamma\pars{\nu}
$$
which can be derived with
Ramanujan's Master Theorem. Namely,
\begin{align}
\int_{0}^{\infty}x^{\nu - 1}\sin\pars{x}\,\dd x & =
\Im\int_{0}^{\infty}x^{\nu - 1}\expo{\ic x}\,\dd x =
\Im\int_{0}^{\infty}x^{\nu - 1}
\bracks{\sum_{k = 0}^{\infty}{\pars{\ic x}^{k} \over k!}}\,\dd x
\\[5mm] & =
\Im\int_{0}^{\infty}x^{\nu - 1}
\bracks{\sum_{k = 0}^{\infty}\color{red}
{\expo{-\ic \color{black}{k}\pi/2}}
{\pars{-x}^{k} \over k!}}\,\dd x
\\[5mm] & =
\Im\bracks{\Gamma\pars{\nu}
\color{red}{\expo{-\ic\color{black}{\pars{-\nu}}\pi/2}}} =
\sin\pars{\pi\nu \over 2}\Gamma\pars{\nu}
\end{align}

Derive respect of $\ds{\nu}$:
$$ 
\int_{0}^{\infty}x^{\nu - 1}\ln\pars{x}\sin\pars{x}\,\dd x
=
\cos\pars{\pi\nu \over 2}\,{\pi \over 2}\,\Gamma\pars{\nu} +
\sin\pars{\pi\nu \over 2}\Gamma\pars{\nu}\Psi\pars{\nu}
$$

Examine the last RHS behavior when $\ds{\nu \to 0}$:
\begin{align}
& {\Gamma\pars{\nu + 1} \over \nu}\braces{%
{\pi \over 2}\,\cos\pars{\pi\nu \over 2} +
\sin\pars{\pi\nu \over 2}\bracks{\Psi\pars{\nu + 1} - {1 \over \nu}}}
\\[5mm] & \stackrel{\mrm{as}\ \nu\ \to\ 0}{\sim}\,\,\,
{1 \over \nu}\bracks{{\pi \over 2} +
{\pi\nu \over 2}\pars{-\gamma - {1 \over \nu}}} =
{1 \over \nu}\bracks{
{\pi\nu \over 2}\pars{-\gamma}}
\,\,\,\stackrel{\mrm{as}\ \nu\ \to\ 0}{\to}\,\,\,
\bbx{\large-\,{\pi \over 2}\,\gamma} \\ &
\end{align}
A: Using the identity $\int_0^\infty\log(x)\,e^{-x}\,\mathrm{d}x=-\gamma$, we get
$$
\begin{align}
\int_0^\infty\log(x)\,e^{-\lambda x}\,\mathrm{d}x
&=\frac1\lambda\int_0^{\lambda\infty}(\log(x)-\log(\lambda))\,e^{-x}\,\mathrm{d}x\tag{1a}\\
&=\frac1\lambda\int_0^\infty(\log(x)-\log(\lambda))\,e^{-x}\,\mathrm{d}x\tag{1b}\\
&=-\frac{\gamma+\log(\lambda)}\lambda\tag{1c}
\end{align}
$$
Explanation:
$\text{(1a)}$: substitute $x\mapsto x/\lambda$ ($\mathrm{Re}(\lambda)\gt0$)
$\phantom{\text{(1a):}}$ the path of integration changes if $\lambda\not\in\mathbb{R}$
$\text{(1b)}$: Cauchy says the integrals on $(0,\infty)$ and $(0,\lambda\infty)$ are equal
$\phantom{\text{(1b):}}$ since the integrand vanishes exponentially at $\infty$
$\phantom{\text{(1b):}}$ and there are no singularities in the wedge between $(0,\infty)$ and $(0,\lambda\infty)$
$\text{(1c)}$: apply the identity $\int_0^\infty\log(x)\,e^{-x}\,\mathrm{d}x=-\gamma$
Applying $(1)$ gives
$$
\begin{align}
&\int_0^\infty\sin(x)\log(x)\,e^{-ax}\,\mathrm{d}x\tag{2a}\\
&=\frac1{2i}\int_0^\infty\log(x)\,e^{(i-a)x}\,\mathrm{d}x-\frac1{2i}\int_0^\infty\log(x)\,e^{(-i-a)x}\,\mathrm{d}x\tag{2b}\\
&=-\frac1{2i}\frac{\gamma+\log(a-i)}{a-i}+\frac1{2i}\frac{\gamma+\log(a+i)}{a+i}\tag{2c}
\end{align}
$$
Integrating $(2)$ in $a$ yields
$$
\begin{align}
&\int_0^\infty\frac{\sin(x)\log(x)}x\,e^{-ax}\,\mathrm{d}x\tag{3a}\\
&=\frac\gamma{2i}\log\left(\frac{a-i}{a+i}\right)+\frac1{4i}\left(\log(a-i)^2-\log(a+i)^2\right)\tag{3b}\\
&=-\gamma\tan^{-1}(1/a)-\frac12\log\left(a^2+1\right)\tan^{-1}(1/a)\tag{3c}
\end{align}
$$
Therefore,
$$
\begin{align}
\int_0^\infty\frac{\sin(x)\log(x)}x\,\mathrm{d}x
&=\lim_{a\to0^+}\left(-\gamma\tan^{-1}(1/a)-\frac12\log\left(a^2+1\right)\tan^{-1}(1/a)\right)\tag{4a}\\[6pt]
&=-\frac{\gamma\pi}2\tag{4b}
\end{align}
$$
