If $$\lim_{x\to\infty}f(x)^{g(x)}=e^k\;,$$ then $$k=\ln\lim_{x\to\infty}f(x)^{g(x)}=\lim_{x\to\infty}\ln f(x)^{g(x)}=\lim_{x\to\infty}g(x)\ln f(x)\;.$$ Thus, in order for the method to work, we must have $$\lim_{x\to\infty}g(x)\ln f(x)=\lim_{x\to\infty}g(x)\left(f(x)-1\right)\;.$$
Using the Maclaurin series for $\ln(1+x)$, we have
$$\begin{align*} \ln f(x)&=\ln\left(1+f(x)-1\right)\\ &=\sum_{n\ge 1}(-1)^{n+1}\frac{\left(f(x)-1\right)^n}n\\ &\approx f(x)-1 \end{align*}$$
once $f(x)$ is close to $1$, and the error is bounded by $\frac12\left(f(x)-1\right)^2$, which decreases rapidly compared with $|f(x)-1|$.
You can also compare what happens when you apply l’Hospital’s rule to $$\lim_{x\to\infty}\frac{\ln f(x)}{1/g(x)}$$ and to $$\lim_{x\to\infty}\frac{f(x)-1}{1/g(x)}\;:$$ the former gives you $$\lim_{x\to\infty}\frac{f\,'(x)/f(x)}{-\left(g(x)\right)^{-2}g'(x)}=\lim_{x\to\infty}\frac1{f(x)}\lim_{x\to\infty}\frac{f\,'(x)}{-\left(g(x)\right)^{-2}g'(x)}=\lim_{x\to\infty}\frac{f\,'(x)}{-\left(g(x)\right)^{-2}g'(x)}\;,$$ which is exactly what the latter gives you.