An integral that needs subtitution to be solved. I have this excercise. The hint is that it's solved by the substitution method, but I'm not able to find the right one, or even get close to something.

$$\int\frac{\sec(x)}{\sin(x)+\cos(x)}dx$$

Using identities, I have arrived to things like this:
$$-\int\frac{\tan(x)-1}{\cos(2x)}dx$$
But, well, the thing above doesn't help too much.
I'd appreciate any help on this subject.
 A: Here's a solution using a substitution.
In particular, observe that $$\frac{\sec x}{\sin x+\cos x}\cdot\frac{\sec x}{\sec x}=\frac{\sec^2 x}{\tan x+1}.$$ This is useful because $\frac{d}{dx}\tan x=\sec^2x$, so substituting $u=\tan x$ tells us that $$\int\frac{\sec x}{\sin x+\cos x}dx=\int\frac{1}{u+1}du=\ln(|u+1|)=\ln(|\tan x+1|).$$
Since $\tan x=\frac{\sin x}{\cos x}$, we find that this is simply equal to $$\ln\left(\frac{\sin x+\cos x}{\cos x}\right)=\ln\left(|\sin x+\cos x|\right)-\ln\left(|\cos x|\right).$$
A: I hope that you don't mind if I don't use a substitution. Note that\begin{align}\int\frac{\sec(x)}{\sin(x)+\cos(x)}\,\mathrm dx&=\int\frac1{\sin(x)\cos(x)+\cos^2(x)}\,\mathrm dx\\&=\int\frac{\cos(x)-\sin(x)}{\cos(x)+\sin(x)}+\frac{\sin(x)}{\cos(x)}\,\mathrm dx\\&=\log\bigl(\lvert\cos(x)+\sin(x)\rvert\bigr)-\log\bigl(\lvert\cos(x)\rvert\bigr).\end{align}
A: You can observe that
$$
\frac{\sec x}{\sin x+\cos x}=\frac{1}{\cos x(\sin x+\cos x)}=
\frac{\sin^2x+\cos^2x}{\cos x(\sin x+\cos x)}=
\frac{\tan^2x+1}{\tan x+1}
$$
A rational function in the tangent can be integrated via
$$
u=\tan x
$$
so $du=(1+\tan^2x)\,dx$ or
$$
dx=\frac{1}{u^2+1}\,du
$$
and the integral is now elementary.
