How to prove $\int_0^\infty\frac {\tanh(x)-x\exp(-x)}{x^2}dx=\frac{\zeta'(0)}{\zeta(0)}-\frac{\zeta'(2)}{\zeta(2)}+\gamma-\frac73\log(2)$? By educated guessing, inspired by this solution of $\int_0^\infty\frac {\tanh^3(x)}{x^2}dx$, I have found numerically: $$\int\limits_0^\infty\frac {\tanh(x)-x\exp(-x)}{x^2}dx=\frac{\zeta'(0)}{\zeta(0)}-\frac{\zeta'(2)}{\zeta(2)}+\gamma-\frac73\log(2).$$ The method should be similar to the quoted one, i.e. applying the residue theorem to a keyhole contour integral: $$  \frac{1}{2\pi i} \oint \frac {\tanh(z)-z\exp(-z)}{z^2}\log(-z) \, dz.$$ While I guessed correctly that, unlike in the original one, a term with $\gamma=-\int\limits_0^\infty\exp(-x)\log(x)dx$ will survive even in a more elegantly written closed form, I have a hard time understanding how/why the "regulating part" $\dfrac {\exp(-z)}{z}$ contributes to the sum of residues.
Even if it contributed its own residue at $z=0$ (but how can it, as $z=0$ is outside the contour?), I wouldn't see how this residue could lead to $\gamma$.
Any hints, please?
 A: The way a computation of an integral along an unbounded contour reduces to a sum of residues is often left unjustified, as is done in the linked MO post. In fact this requires an analysis of the behavior of the integrand around $z=\infty$; for $z^{-2}\tanh^3 z$, one takes a bounded part of the contour (say, with $|z|<R$), makes it closed (say, the boundary of $[-R,R]+i\pi[-N,N]$ slit along the positive real axis, where $N$ is an integer), and shows that all the "extra" things vanish in the limit (as $N,R\to\infty$). In our case this doesn't work because of the blow-up of $e^{-z}$ as $\Re z\to-\infty$. Still this can be fixed (see the answer by @Svyatoslav).
Another approach (cf.) is as follows. For $a,b\geqslant 0$ and $0<\Re s<1$ we have $$\int_0^\infty x^{s-2}(e^{-ax}-e^{-bx})\,dx=\frac{\Gamma(s)}{1-s}(b^{1-s}-a^{1-s})$$ (say, use $e^{-ax}-e^{-bx}=x\int_a^b e^{-xy}\,dy$ and justify the $dy\,dx\mapsto dx\,dy$), then we find $$\int_0^\infty x^{s-2}\tanh x\,dx=\frac{\Gamma(s)}{1-s}\sum_{n=0}^\infty\big(2(4n+2)^{1-s}-(4n)^{1-s}-(4n+4)^{1-s}\big)$$ (use $\tanh x=(1-e^{-2x})^2\sum_{n=0}^\infty e^{-4nx}$ and DCT for termwise integration). The sum equals $2^{2-s}(1-2^{2-s})\zeta(s-1)$ (compute $\sum_{n=1}^\infty$ for $\Re s>2$, and use analytic continuation; the last function of $s$ is entire). Thus we get (still for $0<\Re s<1$) $$\int_0^\infty x^{s-2}(\tanh x-xe^{-x})\,dx=\Gamma(s)\big(f(s)-1\big),\\f(s):=\frac{2^{2-s}}{1-s}(1-2^{2-s})\zeta(s-1).$$
It just remains to take $s\to 0^+$; then $f(s)\to 1$, hence the limit is $$\int_0^\infty\frac{\tanh x-xe^{-x}}{x^2}\,dx=f'(0)=1-12\zeta'(-1)-\frac73\log2.$$
The expression stated in the OP now follows from the relation between $\zeta'(-1)$ and $\zeta'(2)$ one obtains from the functional equation for $\zeta$, as well as the value of $\zeta'(0)$. Note also that $1-12\zeta'(-1)=12\log A$, where $A$ is the Glaisher–Kinkelin constant.
A: To the nice solution by @metamorphy and solutions of the similar problem (the link provided by @Random Variable) I would like to add the heuristic solution via complex integration. I hope it brings some value, too.
Let's denote
$$I=\int_0^\infty\Big(\frac{\tanh x}{x^2}-\frac{e^{-x}}{x}\Big)dx$$
We will consider instead
$$I_\epsilon=\int_0^\infty\Big(x^{\epsilon-2}\tanh x \,-e^{-x}x^{\epsilon-1}\Big)dx=I_{1\epsilon}+I_{2\epsilon}$$
where we keep $\epsilon\ll1$ but fixed, and will take the limit $\epsilon\to0$ at the end of our evaluation.
Now we have the regularized integrals and can treat them separately. The second term
$$I_{2\epsilon}=-\int_0^\infty e^{-x}x^{\epsilon-1}dx=-\Gamma(\epsilon)=-\frac{1}{\epsilon}+\gamma+O(\epsilon)$$
To evaluate the first term, we go to the complex plane and integrate along the keyhole contour:

$$\oint z^{\epsilon-2}\tanh z \,dz=I_{1\epsilon}\big(1-e^{2\pi i\epsilon}\big)+I_r+I_R=2\pi i\sum\operatorname{Res}z^{\epsilon-2}\tanh z$$
where $I_r, I_R$ denote integration along a small circle around $z=0$ with the radius $r\to0$ and along a big circle of the radius $R\to\infty$ correspondingly. It is not difficult to show that both integral tend to zero. We have simple poles inside the contour at $z=\big(\frac{\pi}{2}+\pi k\big)e^{\pi i/2}$ and $z=\big(\frac{\pi}{2}+\pi k\big)e^{3\pi i/2}$.
The residue evaluation is straightforward. Keeping only the terms $O(1)$, we get
$$I_{1\epsilon}=\frac{2}{\epsilon}\sum_{k=0}^\infty\frac{1+\epsilon\ln\big(\frac{\pi}{2}+\pi k\big)}{\big(\frac{\pi}{2}+\pi k\big)^2}+O(\epsilon)$$
Using
$$\sum_{k=0}^\infty\frac{1}{\big(\frac{\pi}{2}+\pi k\big)^2}=\frac{4}{\pi^2}\sum_{k=0}^\infty\frac{1}{\big(1+2k\big)^2}=\frac{1}{2}$$
and
$$\sum_{k=0}^\infty\frac{\ln(1+2k)}{(1+2k)^l}=-\frac{\partial}{\partial l}\sum_{k=0}^\infty\frac{1}{(1+2k)^l}=-\frac{\partial}{\partial l}\zeta(l)(1–2^{-l})=-\zeta’(l)(1–2^{-l})-\frac{\ln2\,\zeta(l)}{2^l}$$
(where $\zeta(l)$ denotes zeta-function), we get
$$2\sum_{k=0}^\infty \frac{\ln\big(\frac{\pi}{2}+\pi k\big)}{\big(\frac{\pi}{2}+\pi k\big)^2}=\ln\frac{\pi}{2}-\frac{\ln2}{3}-\frac{6\,\zeta’(2)}{\pi^2}$$
$$I_\epsilon=I_{1\epsilon}+I_{2\epsilon}=\frac{1}{\epsilon}+\ln\frac{\pi}{2}-\frac{\ln2}{3}-\frac{6\,\zeta’(2)}{\pi^2}-\frac{1}{\epsilon}+\gamma+O(\epsilon)$$
As expected, the diverging terms cancel. Taking the limit $\epsilon\to0$ and using the expression for $\zeta’(2)$, we get the answer in the form provided by @metamorphy.
