Alternative approaches to showing that $\gamma=\int_0^\infty \left(\frac{1}{1+x^a}-\frac{1}{e^x}\right)\,\frac1x\,dx$, $a>0$
Integrating by parts, $$ \int_0^{\infty} \left( \frac{1}{1+x^a} - e^{-x} \right) \frac{dx}{x} = 0-0 + \int_0^{\infty} \left( \frac{ax^a}{x(1+x^a)^2} - e^{-x} \right) \log{x} \, dx $$
Of course, we recognise the second term as a familiar definition of/easy-to-derive formula for $\gamma$. The first term we need to show is zero. But $$ \int \frac{ax^a\log{x}}{x(1+x^a)^2} \, dx = \frac{x^a\log{x}}{1+x^a} - \frac{1}{a}\log{(1+x^a)}, $$ which is continuous and tends to zero at both endpoints since $a>0$.
The really interesting thing about this result in my opinion is that it shows the first term is a complete red herring: let $F$ be continuous and continuously differentiable on $(0,\infty)$ with the following properties:
- $ F(x) = 1 + o(1/\log{x})$ as $x \downarrow 0 $,
- $F(x) = o(x^{-\epsilon})$ as $x \uparrow \infty$ for some $\epsilon>0$,
- $\int_0^{\infty} F'(x) \log{x} \, dx = 0$
Then $$ \gamma = \int_0^{\infty} \left( F(x) - e^{-x} \right) \frac{dx}{x}. $$ The proof is essentially identical to the above: $$ \int_0^{\infty} ( F(x) - e^{-x} ) \frac{dx}{x} = [(F(x) - e^{-x}) \log{x}]_0^{\infty} - \int_0^{\infty} ( F'(x) + e^{-x} ) \log{x} \, dx = \int_0^{\infty} e^{-x} \log{x} \, dx, $$ The integral on the left exists by the first two conditions on $F$, which are also enough to ensure the boundary terms from the integration by parts go to zero.
I thought it might be instructive to present a supplement to the nice solution posted by @Chappers in order to have a self-contained way forward. To that end, we proceed.
In THIS ANSWER, I showed using the integral representation of the Gamma function
$$\Gamma(x)=\int_0^\infty s^{x-1}e^{-s}\,ds \tag 1$$
that Gamma can be expressed as the limit
$$\Gamma(x)=\lim_{n\to \infty}\frac{n^x\,n!}{x(x+1)(x+2)\cdots (x+n)} \tag 2$$
Now, note that $(2)$ can be rewritten as
$$\begin{align} \Gamma(x)&=\lim_{n\to \infty}\frac{e^{x(\log(n)-1-1/2-\cdots -1/n)}\, e^{x}e^{x/2}\cdots e^{x/n}}{x(1+x)(1+x/2)\cdots (1+x/n)} \\\\&=\frac{e^{-\gamma x}}{x}\prod_{n=1}^\infty e^{x/n}\left(1+\frac xn\right)^{-1}\tag 3 \end{align}$$
where $(3)$ gives the well-known Weierstrass product for Gamma.
Differentiating the logarithm of $(3)$ and setting $x=1$ reveals
$$\Gamma'(1)=\Gamma(1)\left(-\gamma -1+\sum_{n=1}^\infty \left(\frac1n-\frac{1}{n+1}\right)\right)=-\gamma \tag 4$$
Differentiating $(1)$ and setting $x=1$ yields
$$\Gamma'(1)=\int_0^\infty \log(x)e^{-x}\,dx \tag 5$$
whence comparing $(4)$ and $(5)$ we obtain the coveted result
$$\int_0^\infty \log(x)e^{-x}\,dx =-\gamma$$
In THIS ANSWER, I showed that that $\gamma$ as given by $\gamma=-\int_0^\infty e^{-x}\,\log(x)\,dx$ is equal to $\gamma$ as expressed by the limit $\gamma=\lim_{n\to \infty}\left(-\log(n)+\sum_{k=1}^n\frac1k\right)$.
The same idea as in my previous answer applies. Notice that
$$ f(x) = \frac{1}{1+x} \quad \Rightarrow \quad \int_{\epsilon}^{\infty} \frac{f(x)}{x} \, dx = -\log\epsilon + \log(1+\epsilon) = -\log\epsilon + o(1) $$
as $\epsilon \to 0^+$. Now from the linked answer above, we find that
\begin{align*} f(x) = e^{-x} &\quad \Rightarrow \quad c(f) = \lim_{R\to\infty} \left( \int_{0}^{R} \frac{ds}{1+s} - \log R \right) - \gamma = -\gamma \\ &\quad \Rightarrow \quad \int_{\epsilon}^{\infty} \frac{e^{-x}}{x} \, dx = -\log\epsilon - \gamma + o(1). \end{align*}
It is worth to remark that the $\gamma$ term above is computed from the identity $\gamma = -\int_{0}^{\infty} e^{-x}\log x \, dx$, which you are already aware of. From this,
\begin{align*} \int_{\epsilon}^{\infty} \frac{1}{x^a + 1} \, \frac{dx}{x} - \int_{\epsilon}^{\infty} e^{-x} \, \frac{dx}{x} &= \frac{1}{a}\int_{\epsilon^a}^{\infty} \frac{1}{x + 1} \, \frac{dx}{x} - \int_{\epsilon}^{\infty} e^{-x} \, \frac{dx}{x}\\ &= \gamma + o(1) \end{align*}
and taking $\epsilon \to 0^+$ gives the result.
Using the quantity $c(f)$, you can compute various integrals (including all the integrals you have asked) together with some tabulated results for $c(f)$:
\begin{align*} c\left\{\frac{1}{(1+x)^\alpha}\right\} &= -H_{\alpha-1}, & c\{e^{-x}\} &= -\gamma, \\ c\left\{\frac{x}{e^x-1}\right\} &= 0, & c\{\cos x\} &= -\gamma, \end{align*}
where $H_n$ is the harmonic numbers. For instance, if $a > 0$ then
\begin{align*} \int_{0}^{\infty} \left( \frac{1}{\sqrt{1+a x}} - e^{-x^2} \right) \frac{dx}{x} &= c\left\{ \frac{1}{\sqrt{1+a x}} - e^{-x^2} \right\} \\ &= c\left\{ \frac{1}{\sqrt{1+a x}} \right\} - c\{e^{-x^2}\} \\ &= c\left\{ \frac{1}{\sqrt{1+x}} \right\} - \log a - \frac{1}{2}c\{e^{-x}\} \\ &= H_{-1/2} - \log a + \frac{\gamma}{2} \\ &= \frac{\gamma}{2} - \log(4a). \end{align*}