Although the integral can be evaluated in a straightforward way using real analysis, I thought it might be instructive to present an approach based on complex analysis. To that end, we now proceed.
We use Euler's Formula, $e^{ix}=\cos(x)+i\sin(x)$, to write $\displaystyle \sec(x)=\frac2{e^{ix}+e^{-ix}}=\frac{2e^{ix}}{1+e^{i2x}}$. Then, we have
$$\begin{align}
\int \sec(x)\,dx&=\int \frac2{e^{ix}+e^{-ix}}\\\\
&=\int \frac{2e^{ix}}{1+e^{i2x}}\,dx \\\\
&=-i2 \int \frac{1}{1+(e^{ix})^2}\,d(e^{ix})\\\\
&=-i2 \arctan(e^{ix})+C\tag 1\\\\
&=\log\left(\frac{1-ie^{ix}}{1+ie^{ix}}\right)+C\tag2\\\\
&=\log\left(-i\left(\frac{1+\sin(x)}{i\cos(x)}\right)\right)+C\tag3\\\\
&=\log(\sec(x)+\tan(x))+C'\tag4
\end{align}$$
NOTES:
In going from $(1)$ to $(2)$, we used the identity $\arctan(z)=i2\log\left(\frac{1-iz}{1+iz}\right) $
In going from $(2)$ to $(3)$, we multiplied the numerator and denominator of the argument of the logarithm function by $1-ie^{ix}$. Then, we used
$$\frac{1-ie^{ix}}{1+ie^{ix}}=\frac{-i2\cos(x)}{2(1-\sin(x))}=-i\frac{1+\sin(x)}{\cos(x)}$$
Finally, in going from $(3)$ to $(4)$, we absorbed the term $\log(-i)$ into the integration constant $C$ and labeled the new integration constant $C'=C+\log(-i)$.