indefinite integration needs $x\sec x$ to be integrated, is it even possible to integrate$x\sec x$? The question says 

Find $$\int \left\{\log \left(\frac{1+\sin2x}{1-\sin2x}\right)^{\cos^2x} +\log\left(\frac{\cos2x}{1+\sin2x}\right)\right\}dx$$

Among many methods which  i have tried, the method which i think i should show is:
$$I=\int \left\{\log \left(\frac{1+\sin2x}{1-\sin2x}\right)^{\cos^2x} +\log\left(\frac{\cos2x}{1+\sin2x}\right)\right\}dx$$
$$=\int \left\{\log \left(\frac{\sin x+\cos x }{-\sin x +\cos x}\right)^{1-\sin^2x} -\log\left(\frac{\sin x+\cos x }{-\sin x +\cos x}\right)\right\}dx$$
$$=\int \left\{\log \left(\frac{\sin x+\cos x }{-\sin x +\cos x}\right)-\sin^2x.\log \left(\frac{\sin x+\cos x }{-\sin x +\cos x}\right) -\log\left(\frac{\sin x+\cos x }{-\sin x +\cos x}\right)\right\}dx$$
$$=\int \left\{-\sin^2x.\log\left(\frac{\sin x+\cos x }{-\sin x +\cos x}\right)\right\}dx$$
now using integration by parts:
$$-I=\log\left(\frac{\sin x+\cos x }{-\sin x +\cos x}\right).\int \sin^2xdx-\int\left(\frac{2}{\cos 2x}\int \sin^2xdx\right)dx$$
$$=\log\left(\frac{\sin x+\cos x }{-\sin x +\cos x}\right).\left(\frac x2-\frac{\sin 2x}{4}\right)-\int \frac{x-(\sin2x)/2}{\cos 2x}$$
$$\log\left(\frac{\sin x+\cos x }{-\sin x +\cos x}\right).\left(\frac x2-\frac{\sin 2x}{4}\right)+\frac 12.\int \tan 2x dx-\int x\sec x dx$$
see everything is fine except for the last  term of -I which i am not able to evaluate.
is there the integration of $\int x\sec x dx$ even possible? if not, what approach should i adopt?

ANSWER: $$\frac{\sin 2x}{2}.\log\left(\frac{\cos x+\sin x}{\cos x-\sin x}\right)+\frac 12 \log|\cos 2x| +c$$
 A: This does not answer the problem of $\int x \sec(x)\,dx$ which is not needed in my approach.
Considering the integrand $$\log \left(\frac{1+\sin(2x)}{1-\sin(2x)}\right)^{\cos^2(x)} +\log\left(\frac{\cos(2x)}{1+\sin(2x)}\right)$$ rewrite it as $${\cos^2(x)}\log \left(\frac{1+\sin(2x)}{1-\sin(2x)}\right)+\log\left(\frac{\cos(2x)}{1+\sin(2x)}\right)$$ So, as you did, using $$1+\sin(2x)=(\cos(x)+\sin(x))^2$$ $$1-\sin(2x)=(\cos(x)-\sin(x))^2$$ $$\cos(2x)=(\cos(x)+\sin(x))\times(\cos(x)-\sin(x))$$ after simplifications (basically as you did), the integrand reduces to $$\cos (2 x) \log \left(\frac{\sin (x)+\cos (x)}{\cos (x)-\sin (x)}\right)$$ So, consider $$I=\int \cos (2 x) \log \left(\frac{\sin (x)+\cos (x)}{\cos (x)-\sin (x)}\right)\,dx$$ and integrate by parts $$u=\log \left(\frac{\sin (x)+\cos (x)}{\cos (x)-\sin (x)}\right)\implies u'=2 \sec (2 x)\,dx$$ $$v'=\cos(2x)\,dx\implies v=\frac{1}{2} \sin (2 x)$$ which make $$I=\frac{1}{2} \sin (2 x) \log \left(\frac{\sin (x)+\cos (x)}{\cos (x)-\sin
   (x)}\right)-\int \tan (2 x)\,dx$$ that is to say $$I=\frac{1}{2} \sin (2 x) \log \left(\frac{\sin (x)+\cos (x)}{\cos (x)-\sin
   (x)}\right)+\frac{1}{2} \log (\cos (2 x))$$ which is the answer you gave at the end of the post.
A: i gtot this answer here
$$x^2+x \left(-x+\cos ^2(x) \left(-\log \left(\frac{(\sin (x)+\cos (x))^2}{(\cos
   (x)-\sin (x))^2}\right)\right)+\log \left(\left(\frac{(\sin (x)+\cos
   (x))^2}{(\cos (x)-\sin (x))^2}\right)^{\cos ^2(x)}\right)\right)+x \log
   \left(\frac{\cos (2 x)}{\sin (2 x)+1}\right)+\frac{1}{2} (x+\log (\cos
   (x)-\sin (x)))+\frac{1}{2} (\log (\sin (x)+\cos (x))-x)+\frac{1}{4} (2 x+\sin
   (2 x)) \log \left(\frac{(\sin (x)+\cos (x))^2}{(\cos (x)-\sin (x))^2}\right)$$
