Evaluate $\int_0^{{\pi}/{2}} \log(1+\cos x)\, dx$

Using Weierstrass substitution $$ t=\tan\frac x2\qquad;\qquad\cos x=\frac{1-t^2}{1+t^2}\qquad;\qquad dx=\frac{2}{1+t^2}\ dt $$ we obtain \begin{align} \int_0^{\Large\frac\pi2}\ln(1+\cos x)\ dx&=2\underbrace{\int_0^1\frac{\ln2}{1+t^2}\ dt}_{\color{blue}{\text{set}\ t=\tan\theta}}-2\color{red}{\int_0^1\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt}\\ &=\frac{\pi}{2}\ln2-2\color{red}{\int_0^1\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt}.\tag1 \end{align} Consider \begin{align} \int_0^\infty\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt&=\int_0^1\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt+\underbrace{\int_1^\infty\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt}_{\large\color{blue}{t\ \mapsto\ \frac1t}}\\ &=2\int_0^1\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt-2\int_0^1\frac{\ln t}{1+t^2}\ dt\\ \color{red}{\int_0^1\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt}&=\frac12\underbrace{\int_0^\infty\frac{\ln\left(1+t^2\right)}{1+t^2}\ dt}_{\color{blue}{\text{set}\ t=\tan\theta}}+\int_0^1\frac{\ln t}{1+t^2}\ dt\\ &=-\underbrace{\int_0^{\Large\frac\pi2}\ln\cos\theta\ d\theta}_{\color{blue}{\Large\text{*}}}+\sum_{k=0}^\infty(-1)^k\underbrace{\int_0^1 t^{2k}\ln t\ dt}_{\color{blue}{\Large\text{**}}}\\ &=\frac\pi2\ln2-\sum_{k=0}^{\infty} \frac{(-1)^k}{(2 k+1)^2}\\ &=\frac\pi2\ln2-\text{G},\tag2 \end{align} where $\text{G}$ is Catalan's constant.

$(*)$ can be proven by using the symmetry of $\ln\cos\theta$ and $\ln\sin\theta$ in the interval $\left[0,\frac\pi2\right]$ and $(**)$ can be proven by using formula $$ \int_0^1 x^\alpha \ln^n x\ dx=\frac{(-1)^n n!}{(\alpha+1)^{n+1}}, \qquad\text{for }\ n=0,1,2,\ldots $$ Thus, plugging in $(2)$ to $(1)$ yields \begin{align} \int_0^{\Large\frac\pi2}\ln(1+\cos x)\ dx =\large\color{blue}{2\text{G}-\frac{\pi}{2}\ln2}. \end{align}


Here is a formula I find quite useful: $$ \begin{align} \log(1+\cos(x)) &=\log\left(\frac{e^{ix}+2+e^{-ix}}{2}\right)\tag{1}\\ &=2\log\left(e^{ix/2}+e^{-ix/2}\right)-\log(2)\tag{2}\\ &=2\left[ix/2+\log\left(1+e^{-ix}\right)\right]-\log(2)\tag{3}\\ &=2\left[-ix/2+\log\left(1+e^{ix}\right)\right]-\log(2)\tag{4}\\ &=\log\left(1+e^{ix}\right)+\log\left(1+e^{-ix}\right)-\log(2)\tag{5}\\ &=\sum_{k=1}^\infty(-1)^{k-1}\frac{e^{ikx}}{k}+\sum_{k=1}^\infty(-1)^{k-1}\frac{e^{-ikx}}{k}-\log(2)\tag{6}\\ &=2\sum_{k=1}^\infty(-1)^{k-1}\frac{\cos(kx)}{k}-\log(2)\tag{7} \end{align} $$ Explanation:
$(1)$: $\cos(x)=\frac{e^{ix}+e^{-ix}}{2}$
$(2)$: pull out the $\log(2)$ and use $\left(e^{ix/2}+e^{-ix/2}\right)^2=e^{ix}+2+e^{-ix}$
$(3)$: pull $e^{ix/2}$ out of $\log\left(e^{ix/2}+e^{-ix/2}\right)$ in $(2)$
$(4)$: pull $e^{-ix/2}$ out of $\log\left(e^{ix/2}+e^{-ix/2}\right)$ in $(2)$
$(5)$: average $(3)$ and $(4)$
$(6)$: use the power series for $\log(1+x)$
$(7)$: $\cos(x)=\frac{e^{ix}+e^{-ix}}{2}$


Apply the formula above to the integral in the question: $$ \begin{align} \int_0^{\pi/2}\log(1+\cos(x))\,\mathrm{d}x &=2\sum_{k=1}^\infty\frac{(-1)^{k-1}}{k}\int_0^{\pi/2}\cos(kx)\,\mathrm{d}x-\frac\pi2\log(2)\\ &=2\sum_{k=1}^\infty\frac{(-1)^{k-1}}{k^2}\sin(k\pi/2)-\frac\pi2\log(2)\\ &=2\sum_{n=0}^\infty\frac{(-1)^n}{(2n+1)^2}-\frac\pi2\log(2)\\ &=2\mathrm{G}-\frac\pi2\log(2)\tag{8} \end{align} $$ where $\mathrm{G}$ is Catalan's constant.


hint: $$\int\ln[1+\cos(x)]dx=\int\ln\left[2\cos^2\left(\frac{x}{2}\right)\right]dx\\=\int\ln(2)dx+\int\ln\left[\cos^2\left(\frac{x}{2}\right)\right]dx\\=\ln(2)\int dx+2\int\ln\left[\cos\left(\frac{x}{2}\right)\right]dx\\=\ln(2)\int dx+4\int\ln\cos(t)dt\bigg|_{t=x/2}$$ then you can use your helpful integration to have the result.