To integrate $\cot(x)$, recall that
$$ \cot(x) = \frac{\cos(x)}{\sin(x)}\,, $$so
$$ ∫ \cot(x)\,dx = ∫ \frac{\cos(x)}{\sin(x)}\,dx\,. $$ By choosing $u = \sin(x)$, that is, “$du = \cos(x)\,dx$” (in quotation marks because this expression does not make sense mathematically, but it does work formally), we get $$ ∫ \frac{\cos(x)}{\sin(x)}\,dx = ∫ \frac{1}{u}\,du = \log(u)+C = \log(\sin(x))+C $$