Showing that $\int_0^1 \log(\sin \pi x)dx=-\log2$ I need help with a textbook exercise (Stein's Complex Analysis, Chapter 3, Exercises 9). This exercise requires me to show that
$$\int_0^1 \log(\sin \pi x)dx=-\log2$$
A hint is given as "Use the contour shown in Figure 9."

Since this is an exercise from Chapter 3, I think I should use the residue formula or something like that. But the function $f(x)=\log(\sin \pi x)$ becomes singular on $x=0$ and $x=1$, which makes the contour illegal for the residue theorem. Can anyone give me a further hint on this problem? Many thanks in advance!
P.S. This is my first time on Math Stack Exchange. If you find my post ambiguous, let me know.
 A: *

*Riemann sums
It is not a complex analytic technique but I think it is worth mentioning. We can compute the integral by taking Riemann sums and exploiting the identity:
$$\prod_{k=1}^{n-1}\sin\frac{\pi k}{n}=\frac{2n}{2^n}\tag{1}$$
from which it follows that:
$$\begin{eqnarray*}\int_{0}^{1}\log(\sin(\pi x))\,dx &=& \frac{1}{\pi}\int_{0}^{\pi}\log\sin x\,dx = \frac{1}{\pi}\lim_{n\to +\infty}\frac{\pi}{n}\sum_{k=1}^{n-1}\log\sin\frac{\pi k}{n}\\&=&\lim_{n\to +\infty}\frac{1}{n}\,\log\frac{2n}{2^n}=\color{red}{-\log 2}.\tag{2}\end{eqnarray*}$$
Other approaches deserve to be mentioned:


*Symmetry
The function $\sin(\pi x)$ is symmetric with respect to $x=\frac{1}{2}$, hence
$$\begin{eqnarray*}I=\int_{0}^{1}\log\sin(\pi x)\,dx&\stackrel{x\to 2z}{=}&2\int_{0}^{1/2}\left[\log(2)+\log\sin(\pi z)+\log\cos(\pi z)\right]\,dz\\&=&\log(2)+2I.\end{eqnarray*}\tag{3}$$


*An obscene overkill
By Raabe's theorem $\int_{a}^{a+1}\log\Gamma(x)\,dx = \log\sqrt{2\pi}+a\log a-a$ and by the reflection formula for the $\Gamma$ function $\frac{\pi}{\sin(\pi z)}=\Gamma(z)\Gamma(1-z)$, hence the question is trivial by switching to logarithms and integrating over $(0,1)$.
A: Consider $$f(z) = \log(1-e^{2 \pi zi }) = \log(e^{\pi zi}(e^{-\pi zi}-e^{\pi zi})) = \log(-2i) + \pi zi + \log(\sin(\pi z))$$
Then we have
\begin{align}
\int_0^1 f(z) dz & = \log(-2i) + \dfrac{i \pi}2 + \int_0^1 \log(\sin(\pi z))dz\\
& = \int_0^1 \log(\sin(\pi z))dz + \log(-2i) + \log(i)\\
& = \log(2) + \int_0^1 \log(\sin(\pi z))dz
\end{align}
Now it suffices to show that $\displaystyle \int_0^1 f(z) dz = 0$. Consider the contour $C(\epsilon,R)$ (which is the contour given in your question) given by the following.
$1$. $C_1(\epsilon,R)$: The vertical line along the imaginary axis from $iR$ to $i \epsilon$.
$2$. $C_2(\epsilon)$: The quarter turn of radius $\epsilon$ about $0$.
$3$. $C_3(\epsilon)$: Along the real axis from $(\epsilon,1-\epsilon)$.
$4$. $C_4(\epsilon)$: The quarter turn of radius $\epsilon$ about $1$.
$5$. $C_5(\epsilon,R)$: The vertical line from $1+i\epsilon$ to $1 + iR$.
$6$. $C_6(R)$: The horizontal line from $1+iR$ to $iR$.
$f(z)$ is analytic inside the contour $C$ and hence $\displaystyle \oint_C f(z) = 0$. This gives us
$$\int_{C_1(\epsilon,R)} f dz + \int_{C_2(\epsilon)} f dz + \int_{C_3(\epsilon)} f dz + \int_{C_4(\epsilon)} f dz + \int_{C_5(\epsilon,R)} f dz + \int_{C_6(R)} f dz = 0$$
Now the integral along $1$ cancels with the integral along $5$ due to symmetry. Integrals along $2$ and $4$ scale as $\epsilon \log(\epsilon)$. Integral along $6$ goes to $0$ as $R \to \infty$. This gives us $$\lim_{\epsilon \to 0} \int_{C_3(\epsilon)} f dz = 0$$ which is what we need.

EDIT
@Did has given the standard way to evaluate this integral using real analysis techniques. Here is another way to prove it.
From integration by parts/ other techniques, we have that $$\int_0^{\pi/2} \sin^{2k}(x) dx = \frac{2k-1}{2k}\frac{2k-3}{2k-2} \cdots \frac{1}{2} \frac{\pi}{2} = \dfrac{(2k)!}{4^k (k!)^2} \dfrac{\pi}2 = \dfrac{\Gamma(2k+1)}{4^k \Gamma^2(k+1)} \dfrac{\pi}2$$
Hence, the analytic extension of $\displaystyle \int_0^{\pi/2} \sin^{2z}(x) dx $ is $\dfrac{\Gamma(2z+1)}{4^z \Gamma^2(z+1)} \dfrac{\pi}2$. (This needs to be justified)
Now differentiate both sides with respect to $z$, and set $z=0$, to get $$2 \int_0^{\pi/2} \log(\sin(x)) = -\dfrac{\pi}2 \log(4)$$
Hence, we get that $$\int_0^{\pi/2} \log(\sin(x)) dx = -\dfrac{\pi}2 \log(2)$$
This also provides you a way to evaluate $\displaystyle \int_0^{\pi/2} \sin^{n}(x) \log(\sin(x)) dx$.
A: The integral $I$ to be computed is
$$
I=2\int_0^{1/2}\log(\sin\pi x)\mathrm dx\stackrel{x\to 1/2-x}{=}2\int_0^{1/2}\log(\cos\pi x)\mathrm dx.
$$
Summing up yields
$$
2I=2\int_0^{1/2}\log(\cos\pi x\sin\pi x)\mathrm dx=2\int_0^{1/2}\log(\sin2\pi x)\mathrm dx-2\int_0^{1/2}\log(2)\mathrm dx.
$$
The first integral on the RHS is
$$
\int_0^{1/2}\log(\sin2\pi x)\mathrm dx\stackrel{x\to2x}{=}\int_0^{1}\log(\sin\pi x)\frac{\mathrm dx}2=\frac{I}2,
$$
and the second integral on the RHS is easy, hence $2I=I-\log2$ and, finally,
$$
I=-\log2.
$$
