How to prove $\int_0^\infty \ln(1+\frac{z}{\cosh(x)})dx=\frac{\pi^2}{8}+\frac{(\cosh^{-1}(z))^2}{2},z\ge1$ and a closed form for $-1<z<1$?

Substitute $z=\frac{1-w^2}{1+w^2}$, the original integral turns into $$I(w)=\int_0^\infty\ln\left(1+\frac{1-w^2}{1+w^2}\operatorname{sech} x\right)dx.$$ Use Feymann's trick, $$I'(w)=\int_0^\infty\frac{-4w}{1-w^4+(1+w^2)^2\cosh x}dx$$ Recall $\cosh x=\frac12(e^x+e^{-x})$, $$I'(w)=\int_0^\infty\frac{-4w}{1-w^4+(1+w^2)^2\frac12(e^x+e^{-x})}dx\\ =\int_0^\infty\frac{-4we^x}{(1-w^4)e^x+(1+w^2)^2\frac12(e^{2x}+1)}dx\\ =\int_0^\infty\frac{-4w}{(1-w^4)e^x+(1+w^2)^2\frac12(e^{2x}+1)}de^x\\ =-4\frac{\arctan w}{1+w^2}$$ $$I(w)=I(0)+\int_0^w -4\frac{\arctan l}{1+l^2}dl\\ =\int_0^\infty\ln(1+\operatorname{sech}(x))dx-2\arctan^2w\\ =\frac{\pi^2}8-2\arctan^2w$$ Now, solve $z=\frac{1-w^2}{1+w^2}$ w.r.t. $w$ and use $-2\arctan^2\sqrt{\frac{1-z}{1+z}}=\frac12\operatorname{arccosh}^2 z$, we get $$f(z)=\frac{\pi^2}{8}+\frac{(\cosh^{-1}(z))^2}{2},z>-1.$$ The formula is valid when $z\in[-1,1]$ if we consider $\cosh^{-1}$ as a complex-valued function. If you don't like this representation, just deduce $f(z)=\frac{\pi^2}{8}-\frac{(\arccos(z))^2}{2}$ using some algebra.


Here is a more direct way.

The first thing to note is the function $f(z)$ is continuous for all $z > - 1$, including at the point $z = 1$.

From $$f(z) = \int_0^\infty \ln (1 + z \operatorname{sech} x) \, dx,$$ on differentiating with respect to $z$ we have \begin{align} f'(z) &= \int_0^\infty \frac{\operatorname{sech} x}{1 + z \operatorname{sech}} \, dx\\ &= \int_0^\infty \frac{dx}{\cosh x + z}\\ &= 2 \int_0^\infty \frac{e^x}{e^{2x} + 2z e^x + 1} \, dx. \end{align} In the last line we have used the fact that $\cosh x = (e^{x} + e^{-x})/2$.

Making a substitution of $u = e^x, du = e^x \, dx$ leads to $$f'(z) = 2 \int_1^\infty \frac{du}{(u + z)^2 + 1 - z^2}. \qquad (*)$$


Case 1: $-1 < z < 1$

For this case, as the term $(1 - z^2)$ will be positive we can write ($*$) as: \begin{align} f'(z) &= 2 \int_1^\infty \frac{du}{(u + z)^2 + (\sqrt{1 - z^2})^2}\\ &= \frac{2}{\sqrt{1 - z^2}} \left [\tan^{-1} \left (\frac{u + z}{\sqrt{1 - z^2}} \right ) \right ]_1^\infty\\ &= \frac{\pi}{\sqrt{1 - z^2}} - \frac{2}{\sqrt{1 - z^2}} \tan^{-1} \left (\frac{1 + z}{\sqrt{1 - z^2}} \right )\\ &= \frac{\pi}{\sqrt{1 - z^2}} - \frac{2}{\sqrt{1 - z^2}} \left [\frac{\pi}{2} - \tan^{-1} \left (\frac{\sqrt{1 - z^2}}{1 + z} \right ) \right ]\\ &= \frac{2}{\sqrt{1 - z^2}} \tan^{-1} \left (\frac{\sqrt{1 - z^2}}{1 + z} \right ), \qquad (**) \end{align} where we have made use of the result $\tan^{-1} (x) = \pi/2 - \tan^{-1} (1/x)$ for $x > 0$.

Noting that $$\tan \left (\frac{1}{2} \cos^{-1} z \right ) = \frac{\sqrt{1 - z^2}}{1 + z},$$ the result in ($**$) can be rewritten as $$f'(z) = \frac{1}{\sqrt{1 - z^2}} \cos^{-1} z.$$ Integrating up with respect to $z$ it is readily seen that $$f(z) = \int \frac{\cos^{-1} z}{\sqrt{1 - z^2}} \, dz = -\frac{1}{2} (\cos^{-1} z )^2 + C.$$ To find the constant $C$, choosing $z= 0$ we see that $f(0) = 0$. Thus $C = \pi^2/8$, leading to $$f (z) = \frac{\pi^2}{8} - \frac{1}{2} (\cos^{-1} z)^2, \, -1 < z < 1. \qquad (\dagger)$$


Case 2: $z > 1$

For this case, as the term $(1 - z^2)$ will be negative we can write ($*$) as: \begin{align} f'(z) &= 2 \int_1^\infty \frac{du}{(u + z)^2 - (\sqrt{z^2 - 1})^2}\\ &= -\frac{2}{\sqrt{z^2 - 1}} \left [\coth^{-1} \left (\frac{u + z}{\sqrt{z^2 - 1}} \right ) \right ]_1^\infty\\ &= \frac{2}{\sqrt{z^2 - 1}} \coth^{-1} \left (\frac{1 + z}{\sqrt{z^2 - 1}} \right )\\ &= \frac{2}{\sqrt{z^2 - 1}} \tanh^{-1} \left (\frac{\sqrt{z^2 - 1}}{z+ 1} \right ), \qquad (***) \end{align} where we have made use of the result $\coth^{-1} (x) = \tanh^{-1} (1/x), x \neq 0$.

Noting that $$\tanh \left (\frac{1}{2} \cosh^{-1} z \right ) = \frac{\sqrt{z^2 - 1}}{z + 1},$$ the result in ($***$) can be written as $$f'(z) = \frac{1}{\sqrt{z^2 - 1}} \cosh^{-1} z.$$ Integrating up with respect to $z$ it is readily seen that $$f(z) = \int \frac{\cosh^{-1} z}{\sqrt{z^2 - 1}} \, dz = \frac{1}{2} (\cosh^{-1} z)^2 + C.$$ To find the unknown constant $C$, as the function $f(z)$ is continuous for all $z > - 1$, for $f$ to be continuous at $z = 1$, from ($\dagger$) we require $f(1) = \pi^2/8$. Thus $C = \pi^2/8$, leading to $$f(z) = \frac{\pi^2}{8} + \frac{1}{2} (\cosh^{-1} z)^2, \qquad z > 1.$$


First, $$ \begin{align} \int_0^{\pi/2}\frac{\mathrm{d}\theta}{1+\alpha\sin(\theta)} &=\int_0^1\frac{2\,\mathrm{d}z}{1+2\alpha z+z^2}\tag1\\ &=\frac1{\sqrt{\alpha^2-1}}\int_0^1\left(\frac1{z+\alpha-\sqrt{\alpha^2-1}}-\frac1{z+\alpha+\sqrt{\alpha^2-1}}\right)\mathrm{d}z\tag2\\ &=\frac1{\sqrt{\alpha^2-1}}\left[\log\left(\frac{z+\alpha-\sqrt{\alpha^2-1}}{z+\alpha+\sqrt{\alpha^2-1}}\right)\right]_0^1\tag3\\ &=\frac1{\sqrt{\alpha^2-1}}\log\left(\alpha+\sqrt{\alpha^2-1}\right)\tag4\\ &=\left\{\begin{array}{} \frac1{\sqrt{1-\alpha^2}}\cos^{-1}(\alpha)&\text{if }|\alpha|\le1\\ \frac1{\sqrt{\alpha^2-1}}\cosh^{-1}(\alpha)&\text{if }\alpha\ge1 \end{array}\right.\tag5 \end{align} $$ Explanation:
$(1)$: substitute $z=\tan(\theta/2)$
$(2)$: partial fractions
$(3)$: integrate
$(4)$: evaluate
$(5)$: simplify in different cases

Therefore, $$ \begin{align} \int_0^\infty\log\left(1+\frac{\alpha}{\cosh(x)}\right)\,\mathrm{d}x &=\int_1^\infty\log\left(1+\frac{2\alpha}{u+\frac1u}\right)\frac{\mathrm{d}u}u\tag6\\ &=\int_0^1\log\left(1+\frac{2\alpha}{u+\frac1u}\right)\frac{\mathrm{d}u}u\tag7\\ &=\int_0^{\pi/4}\log\left(1+\alpha\sin(2\theta)\right)\frac{2\,\mathrm{d}\theta}{\sin(2\theta)}\tag8\\ &=\int_0^{\pi/2}\log\left(1+\alpha\sin(\theta)\right)\frac{\mathrm{d}\theta}{\sin(\theta)}\tag9\\ &=\left\{\begin{array}{} \frac{\pi^2}8-\frac12\cos^{-1}(\alpha)^2&\text{if }|\alpha|\le1\\ \frac{\pi^2}8+\frac12\cosh^{-1}(\alpha)^2&\text{if }\alpha\ge1 \end{array}\right.\tag{10} \end{align} $$ Explanation:
$\phantom{1}(6)$: substitute $u=e^x$
$\phantom{1}(7)$: substitute $u\mapsto1/u$
$\phantom{1}(8)$: substitute $u=\tan(\theta)$
$\phantom{1}(9)$: substitute $\theta\mapsto\theta/2$
$(10)$: apply the integral of $(5)$