The indefinite integral
$\displaystyle \int \frac{\ln (x)}{x^2-2 x+1} \, dx$
has the solution
$\ln (1-x)+\frac{x \ln (x)}{1-x} +C$
Taking the limit as $x$ approaches infinity
$\displaystyle \lim_{x\to \infty } \, \left(\ln (1-x)+\frac{x \ln (x)}{1-x}\right)= i \pi$
Also
$\displaystyle \lim_{x\to 0 } \, \left(\ln (1-x)+\frac{x \ln (x)}{1-x}\right)= 0$
This means that
$\displaystyle \int_0^{\infty } \frac{\ln (x)}{x^2-2 x+1} \, dx = i \pi$
However there is the argument that the integration is over the real plane, the limit does not exist as $x$ approaches zero, and a complex solution was found, so there might be a contradiction.
How can this be explained or resolved?
Since$$\ln (1-x)+\frac{x \ln (x)}{1-x}$$is defined only when $x\in(0,1)$, it is not true that$$\lim_{x\to+\infty}\ln (1-x)+\frac{x \ln (x)}{1-x}=i\pi.$$