<s>[INST] Seeking methods to solve $ \int_{0}^{\frac{\pi}{2}} \ln\left|2 + \tan^2(x) \right| \:dx $ As part of going through a set of definite integrals that are solvable using the Feynman Trick, I am now solving the following: 
$$ \int_{0}^{\frac{\pi}{2}} \ln\left|2 + \tan^2(x) \right| \:dx $$
I'm seeking methods using the Feynman Trick (or any method for that matter) that can be used to solve this definite integral. 
 [/INST] My approach
Let 
\begin{align}
\int_{0}^{\frac{\pi}{2}} \ln\left|2 + \tan^2(x) \right| \:dx &= \int_{0}^{\frac{\pi}{2}} \ln\left|1 + \left(1 + \tan^2(x)\right) \right|  \:dx \\
&= \int_{0}^{\frac{\pi}{2}} \ln\left|1 + \sec^2(x) \right| \:dx \\
&= \int_{0}^{\frac{\pi}{2}} \ln\left|\frac{\cos^2(x) + 1}{\cos^2(x)} \right| \:dx \\
&= \int_{0}^{\frac{\pi}{2}} \left[ \ln\left|\cos^2(x) + 1 \right| - \ln\left|\cos^2(x)\right| \right]\:dx \\
&= \int_{0}^{\frac{\pi}{2}}  \ln\left|\cos^2(x) + 1 \right|\:dx - \int_{0}^{\frac{\pi}{2}}  \ln\left|\cos^2(x)\right|\:dx
\end{align}
Now 
$$ \int_{0}^{\frac{\pi}{2}}  \ln\left|\cos^2(x)\right|\:dx = 2\int_{0}^{\frac{\pi}{2}}  \ln\left|\cos(x)\right|\:dx = 2\cdot-\frac{\pi}{2}\ln(2) = -\pi \ln(2)$$
For detail on this definite integral, see guidance here
We now need to solve
$$ \int_{0}^{\frac{\pi}{2}}  \ln\left|\cos^2(x) + 1 \right|\:dx $$
Here, Let 
$$ I(t) = \int_{0}^{\frac{\pi}{2}}  \ln\left|\cos^2(x) + t \right|\:dx $$
Thus, 
$$
 \frac{dI}{dt} = \int_{0}^{\frac{\pi}{2}}  \frac{1}{\cos^2(x) + t}\:dx 
=  \int_{0}^{\frac{\pi}{2}}  \frac{1}{\frac{\cos(2x) + 1}{2} + t}\:dx = 2\int_{0}^{\frac{\pi}{2}}  \frac{1}{\cos(2x) + 2t + 1}\:dx
$$
Employ a change of variable $u = 2x$:
$$\frac{dI}{dt} = \int_{0}^{\pi}  \frac{1}{\cos(u) + 2t + 1}\:du $$
Employ the Weierstrass substitution $\omega = \tan\left(\frac{u}{2} \right)$:
\begin{align}
\frac{dI}{dt} &= \int_{0}^{\infty}  \frac{1}{\frac{1 - \omega^2}{1 + \omega^2} + 2t + 1}\:\frac{2}{1 + \omega^2}\cdot d\omega \\
&= \int_{0}^{\infty}  \frac{1}{t\omega^2 + t + 1} \:d\omega \\
&= \frac{1}{t}\int_{0}^{\infty}  \frac{1}{\omega^2 + \frac{t +  1}{t}} \:d\omega \\
&= \frac{1}{t}\left[\frac{1}{\sqrt{\frac{t+1}{t}}}\arctan\left( \frac{\omega}{\sqrt{\frac{t+1}{t}}}\right)\right]_{0}^{\infty} \\
&= \frac{1}{t}\frac{1}{\sqrt{\frac{t+1}{t}}}\frac{\pi}{2} \\
&= \frac{1}{\sqrt{t}\sqrt{t + 1}}\frac{\pi}{2}
\end{align}
And so, 
$$I(t) = \int \frac{1}{\sqrt{t}\sqrt{t + 1}}\frac{\pi}{2}\:dt = \pi\ln\left| \sqrt{t} + \sqrt{t + 1}\right| + C$$
Now
$$I(0) = \int_{0}^{\frac{\pi}{2}}  \ln\left|\cos^2(x) + 0 \right|\:dx = -\pi \ln(2) = \pi\ln\left|\sqrt{0} + \sqrt{0 + 1} \right| + C \rightarrow C = -\pi \ln(2)$$
And so,
$$I(t) = \pi\ln\left| \sqrt{t} + \sqrt{t + 1}\right| -\pi \ln(2) = \pi\ln\left|\frac{\sqrt{t} + \sqrt{t + 1}}{2} \right|$$
Thus, 
$$I = I(1) = \int_{0}^{\frac{\pi}{2}}  \ln\left|\cos^2(x) + 1 \right|\:dx = \pi\ln\left|\frac{\sqrt{1} + \sqrt{1 + 1}}{2} \right| = \pi\ln\left|\frac{1 + \sqrt{2}}{2} \right| $$
And Finally
\begin{align}
\int_{0}^{\frac{\pi}{2}} \ln\left|2 + \tan^2(x) \right| \:dx &= \int_{0}^{\frac{\pi}{2}}  \ln\left|\cos^2(x) + 1 \right|\:dx - \int_{0}^{\frac{\pi}{2}}  \ln\left|\cos^2(x)\right|\:dx \\
&= \pi\ln\left|\frac{1 + \sqrt{2}}{2} \right| - \left(-\pi \ln(2)\right) \\
&=  \pi\ln\left|1 + \sqrt{2} \right|
\end{align}
</s>