integration by parts $\int \frac{x^{2}+4x}{x+2}\,dx$ $$\int \frac{x^{2}+4x}{x+2}\,dx$$
I have written it in this form:
$$\int \frac{(x+2)^{2}-4}{x+2}\,dx$$: on this stage I try to do integration by parts, which gets me to :
$$\frac{x^{2}}{2}+2x-4\ln\left | {x+2} \right |$$
but it's wrong for some reason. The right answer is : $$\frac{x^{2}+4x+4}{2}-4\ln\left | x+2 \right |$$
Where am I wrong?

Note that we have $$\frac{x^2+4x+4}2-4\ln|x+2|+C=\frac{x^2}2+2x\color{red}{+2}-4\ln|x+2|+C$$ and this is the same as your expression if we let $C_1=C+2$!
A quicker way: $$\int \frac{(x+2)^{2}-4}{x+2}\,dx=\int\left[x+2-\frac4{x+2}\right]\,dx=\frac{x^2}2+2x-4\ln|x+2|\color{blue}{+C}.$$
