Seeking methods to solve $ \int_{0}^{\frac{\pi}{2}} \ln\left|2 + \tan^2(x) \right| \:dx $
If one wishes to use "Feynman's Trick," then begin by defining a function $I(a)$, $a>1$ as given by
$$I(a)=\int_0^{\pi/2}\log(a+\tan^2(x))\,dx \tag1$$
Differentiation of $(1)$ reveals
$$\begin{align} I'(a)&=\int_0^{\pi/2} \frac{1}{a+\tan^2(x)}\,dx\\\\ &=\frac{\pi/2}{a-1}-\frac{\pi/2}{\sqrt a (a-1)}\tag2 \end{align}$$
Integration of $(2)$ yields
$$\begin{align} I(a)&=\frac\pi2\left(\log(a-1)+\log\left(\frac{\sqrt a+1}{\sqrt{a}-1}\right) \right)\\\\ &=\pi \log(\sqrt a+1)\tag3 \end{align}$$
Finally, setting $a=2$ in $(3)$, we obtain the coveted result
$$\int_0^{\pi/2}\log(2+\tan^2(x))\,dx=\pi \log(\sqrt 2+1)$$
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}