Step 1: Substitute the exponential.
Let $t=e^x$, so $e^{2x}=t^2$ and $dx=\dfrac{dt}{t}$. The integral becomes \[ I=\int\frac{t^2-1}{t^2+t+1}\cdot\frac{dt}{t}. \]
Step 2: Factor the numerator.
$t^2-1=(t-1)(t+1)$, so \[ I=\int\frac{(t-1)(t+1)}{t(t^2+t+1)}\,dt. \]
Step 3: Break into partial fractions.
This splits as \[ \frac{t^2-1}{t(t^2+t+1)}=-\frac1t+\frac{2t+1}{t^2+t+1}. \]
Step 4: Integrate the first part.
$\displaystyle\int-\frac1t\,dt=-\log|t|$.
Step 5: Integrate the second part.
Notice $2t+1$ is exactly the derivative of $t^2+t+1$, so $\displaystyle\int\frac{2t+1}{t^2+t+1}\,dt=\log(t^2+t+1)$.
Step 6: Combine and replace $t$.
$I=\log(t^2+t+1)-\log t+c$. With $t=e^x$, $\log t=x$, so \[ I=\log(e^{2x}+e^x+1)-x+c. \] \[ \boxed{\log(e^{2x}+e^x+1)-x+c} \]