If we use the definition of tanx and write the integral as
we see that the numerator sinx is the derivative of the denominator (apart from the minus sign). Hence, the substitution u=cosx will work,
Note: −lncosx+C is only a primitive function in intervals in which cosx=0.