∫ tan(x) dx = ∫ sin(x)/cos(x) dx = Let cos(x) = u -sin(x) dx = du sin(x) dx = -du The integral becomes

- ∫ du/u = -ln|u| = - ln |cos(x)| + C

You do not have a negative sign in your answer.

OR

∫Tan(x)dx=∫sin (x)/cos(x) dx

Let cos (x)=u => du=-sin(x)dx so the integral becomes -∫du/u=-ln u and u must be >0. So you write -ln|u|. Substitute back and get -ln|cosx| and you were off by a sign.