I am trying to show that density function of standard Cauchy distribution is well defined: that $$\int_\mathbb{R} \frac{1}{\pi(1+x^2)}dx=1.$$
I tried the following calculation: $$\int_{-N}^N \frac{1}{\pi(1+z^2)}dz=\int_{-N}^N\frac{i}{2\pi(z+i)}-\frac{i}{2\pi(z-i)}dz$$$$=\frac{i}{2\pi}\log(z+i)\biggr{|}_{-N}^N-\frac{i}{2\pi}\log(z-i)\biggr{|}_{-N}^N$$$$=\frac{i}{2\pi}(\log(N+i)-\log(-N+i))-\frac{i}{2\pi}(\log(N-i)-\log(-N-i))\to 0$$ as $N\to \infty$. The first equality is due to the fact that $$\frac{1}{z+i}-\frac{1}{z-i}=\frac{-2i}{z+1}.$$ The second equality is due to $$\frac{d\log z}{dz}=\frac{1}{z}$$ on a branch of $\log z$.
I know that I should get $1$ for $$\lim_{N\to\infty}\int_{-N}^N \frac{1}{\pi(1+z^2)}dz,$$ but I just couldn't find the mistake in the above calculation.
Where did I make the mistake? Also, how to calculate this integral if one doesn't do it this way?
Edit: following Oliver's comment, I found that I mis-calculated the limit $$\lim_{N\to\infty} \frac{i}{2\pi}(\log(N+i)-\log(-N+i))-\frac{i}{2\pi}(\log(N-i)-\log(-N-i)).$$ Here I am using the principal branch of logarithm, where $\log$ is given by $\log z=\log r+i\theta$. So, the limit should be exactly 1.