The ODE is separable, i.e. you can write
[tex]\dfrac{\mathrm dy}{\mathrm dx}=\tan x\iff\mathrm dy=\tan x\,\mathrm dx[/tex]
Integrating both sides gives the general solution.
[tex]\displaystyle\int\mathrm dy=\int\tan x\,\mathrm dx[/tex]
[tex]y=-\ln|\cos x|+C[/tex]
Given that [tex]y\left(\dfrac\pi4\right)=3[/tex], we have
[tex]3=-\ln\left|\cos\dfrac\pi4\right|+C[/tex]
[tex]3=-\ln\dfrac1{\sqrt2}+C[/tex]
[tex]3-\ln\sqrt2=C[/tex]
and so the particular solution to the IVP is
[tex]y=-\ln|\cos x|+3-\ln\sqrt2[/tex]
[tex]y=3-\ln|\sqrt2\cos x|[/tex]