Cauchy's Theorem on Path Integrals Cauchy's Integral theorem: Let $U$ be a convex open set and suppose $f$ is a function which is analytic on $U$, except possibly at one point, where it is at least continuous. Then $$\int_{\gamma} f(z) dz=0$$
for every closed path in $U$. 
Let $\gamma$ trace the unit circle centered at $0+0i$ in the anticlockwise direction on the set $\mathbb{C}$. 
Then, $\int_{\gamma} \frac{1}{z^2} dz = 0$, which makes sense. 
But then why does $\int_{\gamma} \frac{1}{z} dz = 2\pi i$? 
Both $\frac{1}{z}$ and $\frac{1}{z^2}$ are not defined at $z=0$, but then how does Cauchy's theorem only apply to the latter?
 A: A simpler look at the problem from "another" Cauchy's integral formula perspective, stating:
$$f^{(n)}(a)=\frac{n!}{2\pi i} \int\limits_{\gamma}\frac{f(z)}{(z-a)^{n+1}}dz$$
In this case $a=0$ and $f(z)=1$


*

*for $n=0$ $$1=\frac{1}{2\pi i} \int\limits_{\gamma}\frac{1}{z}dz$$

*for $n=1$ $$1'=0=\int\limits_{\gamma}\frac{1}{z^2}dz$$

A: In fact Cauchy theorem applies when the open set $U$ is simply connected which is the case of convex sets. 
More generally if, on $U$, your function $f$ admits an antiderivative (that is $F$ such that $F'=f$), one has 
$$
\int_\gamma f(z)dz=0
$$
for arbitrary $U$. 
In your case $f(z)=\frac{1}{z^2}$ admits $F(z)=-\frac{1}{z}$ as antiderivative on $\mathbb{C}^*$ whereas $f(z)=\frac{1}{z}$ does not. 
In fact, one can prove the following (can be elaborated on request)

Lemma Let $U\subset \mathbb{C}$ open and $f$ analytic on $U$. Then $f$ admits an antiderivative on $U$ iff $\int_\gamma f(z)dz=0$ for all closed path $\gamma$ in $U$.

A: I would like to elaborate Duchamp’s answer:
Suppose $\ln(z)$ is a well defined function.
Obviously, $$e^{0}=e^{2\pi i}$$ Taking logarithm on both sides, $$\ln(e^{0})=\ln(e^{2\pi i})$$$$0=2 \pi i$$ which is paradoxical.
Therefore we concluded that $\ln(z)$ is not well defined. In fact, it is illegal to take log on both sides when dealing with complex numbers.
Although $e^{0}$ and $e^{2\pi i}$ refers to the same point on the complex plane, their logarithm is different. This property violates the definition of a function.
Actually, because the problematic $\ln(z)$ happens to be the supposed antiderivative of $\dfrac{1}{z}$, the contour integration of $\dfrac{1}{z}$ on the unit circle is not zero as expected^^, but $2 \pi i$ instead.
^^If you have some physics knowledge, walking around a point and then return to the original position do not change most physical states, for example: electric field strength, energy, work done......
