Basicly we begin with sec x. We multiply above and below by sec x + tan x to get:

( sec^2 x + sec x tan x )/ (sec x + tan x )

if we let u = sec x + tan x, we can differentiate to find du = sec^2 x + sec x tan x which happens to be the expression in the numerator, therefore we make the substitutions to get:

1/u du

this is the derivative of ln u. So the answer is ln|u|. We declared u to be sec x + tan x therefore the answer is ln|sec x + tan x| and of course, + C.

Basicly muliplying above and below by sec x + tan x is a nifty trick that gives it the form 1/u du which is easy to integrate.