I have to calculate $$\int_0^\infty\frac{\log x dx}{x^2-1},$$
and the hint is to integrate $\frac{\log z}{z^2-1}$ over the boundary of the domain $$\{z\,:\,r<|z|<R,\,\Re (z)>0,\,\Im (z)>0\}.$$
I don't understand. The boundary of this domain has a pole of the integrand in it, doesn't it? Doesn't it make this method useless?

Following the hint, let $$f(z) = \frac{\log z}{z^2-1}$$ where $\log$ is the principal branch of the complex logarithm. Since $z=1$ is a simple zero for $z^2-1$ and $\log 1 = 0$, the function $f$ has a removable singularity at $z=1$.
Integrate $f$ along the contour. It's easy to check (using standard estimates) that the integral of $f$ along the two quarter-circles tend to $0$ as $R \to \infty$ and $r \to 0^+$. The function $f$ is holomorphic on and inside the contour, so Cauchy's integral theorem will give you (after passing to the limit)
$$ \int_0^\infty \frac{\log x}{x^2-1}\,dx - \int_0^\infty \frac{\log it}{(it)^2-1}\,i\,dt = 0 $$ i.e. $$ \int_0^\infty \frac{\log x}{x^2-1}\,dx = -\int_0^\infty \frac{\log t + i\pi/2}{t^2+1}\,i \,dt = \frac{\pi^2}{4} \tag{*}$$
using $\int_0^\infty \frac{\log t}{1+t^2}\,dt = 0$ (see e.g. this question) and the elementary $\int_0^\infty \frac{1}{1+t^2}\,dt = \frac{\pi}{2}$.
Added As pointed out by robjohn, just take the real part of (*) to finish it off.