$\frac{x^{2}+x+1}{(x+1)^{2}(x+2)}$
Let $\frac{x^{2}+x+1}{(x+1)^{2}(x+2)}=\frac{A}{(x+1)}+\frac{B}{(x+1)^{2}}+\frac{C}{(x+2)}$ ...(1)
$\Rightarrow x^{2}+x+1=A(x+1)(x+2)+B(x+2)+C\left(x^{2}+2 x+1\right)$
$\Rightarrow x^{2}+x+1=A\left(x^{2}+3 x+2\right)+B(x+2)+C\left(x^{2}+2 x+1\right)$
$\Rightarrow x^{2}+x+1=(A+C) x^{2}+(3 A+B+2 C) x+(2 A+2 B+C)$
Equating the coefficients of $x^{2}, x$, and constant term, we obtain
$A+C=1$
$3 A+B+2 C=1$
$2 A+2 B+C=1$
On solving these equations, we obtain
$A=-2, B=1$, and $C=3$
From equation (1), we obtain
$\frac{x^{2}+x+1}{(x+1)^{2}(x+2)}=\frac{-2}{(x+1)}+\frac{3}{(x+2)}+\frac{1}{(x+1)^{2}}$
$\int \frac{x^{2}+x+1}{(x+1)^{2}(x+2)} d x=-2 \int \frac{1}{x+1} d x+3 \int \frac{1}{(x+2)} d x+\int \frac{1}{(x+1)^{2}} d x$
$=-2 \log |x+1|+3 \log |x+2|-\frac{1}{(x+1)}+\mathrm{C}$