<s>[INST] How does $\int_{0}^{\pi/2} \sin x \ln (\sin x)~ dx $ converge to $\ln(2/e)?$ I can solve this integral, 
$$I=\int_{0}^{\pi/2} \sin x \ln (\sin x)~ dx $$
by parts as
$$I=\int_{0}^{\pi/2} \sin x \ln (\sin x) dx=\left (\cos x +\ln \tan \left(\frac{x}{2}\right)- \cos x \ln (\sin x) \right)_{0}^{\pi/2}=-1,$$ as the divergent parts  $\pm \infty$ cancel out. But Mathematica gives $I=\ln(2/e).$ How to resolve this?
 [/INST] I appreciate you may not be seeking this, but you can find the exact value for the integral using the Beta and by extension Gamma Function and it's derivative. 
Here we will to address your integral:
\begin{equation}
I = \int_0^{\frac{\pi}{2}} \sin(x)\ln\left|\sin(x) \right|\:dx
\end{equation}
Here we will approach this integral by considering a general form:
\begin{equation}
 J_{n,m}(a,b) = \int_0^{\frac{\pi}{2}} \ln^n\left|\sin(x) \right| \ln^m\left|\cos(x)\right|\sin^a(x)\cos^b(x)\:dx
\end{equation}
Where $n,m \in \mathbb{Z}$ with $n,m \geq 0$ and $a,b \in \mathbb{R}$. We observe that $I = J_{1,0}(1,0)$. From here we employ the property:
\begin{align}
 \frac{\partial}{\partial c} \left[ \sin^c(x) \right]= \ln\left|\sin(x)\right| \sin^c(x) \Longrightarrow \frac{\partial^n}{\partial c^n} \left[ \sin^c(x) \right]= \ln^n\left|\sin(x)\right| \sin^c(x)  
\end{align}
And so:
\begin{equation}
 \lim_{c \rightarrow a} \frac{\partial^n}{\partial c^n} \left[ \sin^c(x) \right] = \ln^n\left|\sin(x) \right|\sin^a(x)
\end{equation}
Similarly:
\begin{equation}
  \lim_{d \rightarrow b}\frac{\partial^m}{\partial b^m} \left[ \cos^b(x) \right]= \ln^m\left|\cos(x)\right| \cos^b(x)
\end{equation}
Thus, 
\begin{align}
J_{n,m}(a,b)&= \int_0^{\frac{\pi}{2}} \ln^n\left|\sin(x) \right| \ln^m\left|\cos(x)\right|\sin^a(x)\cos^b(x)\:dx \nonumber \\
& = \int_0^{\frac{\pi}{2}} \lim_{c \rightarrow a} \frac{\partial^n}{\partial c^n} \left[ \sin^c(x) \right] \lim_{d \rightarrow b}\frac{\partial^m}{\partial b^m} \left[ \cos^b(x) \right]\:dx
\end{align}
Employing Leibniz's Integral Rule and the Dominated Convergence Theorem, we can draw the partial derivatives and limits outside of the integrand:
\begin{align}
J_{n,m}(a,b) &= \int_0^{\frac{\pi}{2}}\lim_{c \rightarrow a} \frac{\partial^n}{\partial c^n} \left[ \sin^c(x) \right] \lim_{d \rightarrow b}\frac{\partial^m}{\partial b^m} \left[ \cos^b(x) \right]\:dx \nonumber \\
& = \lim_{c \rightarrow a} \lim_{d \rightarrow b} \frac{\partial^n}{\partial c^n} \frac{\partial^m}{\partial d^m} \int_0^{\frac{\pi}{2}}\sin^c(x)\cos^d(x)\:dx \nonumber \\
&= \lim_{(c,d)\rightarrow (a,b)}\frac{\partial^{n+m}}{\partial c^n \partial d^m} \left[ \frac{1}{2}B\left(\frac{c + 1}{2}, \frac{d + 1}{2} \right) \right] 
\end{align}
Where $B(x,y)$ is the Beta Function. Employing the relationship between the Beta and Gamma Function this becomes:
\begin{align}
J_{n,m}(a,b) &= \frac{1}{2}  \lim_{(c,d)\rightarrow (a,b)}\frac{\partial^{n+m}}{\partial c^n \partial d^m} \left[ \frac{\Gamma\left( \frac{c + 1}{2}\right)\Gamma\left( \frac{d + 1}{2}\right)}{\Gamma\left( \frac{c + d}{2} + 1\right)} \right] 
\end{align}
Returning to your integral $I$:
\begin{align}
I &= J_{1,0}(1,0) = \frac{1}{2}\lim_{(c,d)\rightarrow (1,0)} \frac{\partial}{\partial c} \left[ \frac{\Gamma\left( \frac{c + 1}{2}\right)\Gamma\left( \frac{d + 1}{2}\right)}{\Gamma\left( \frac{c + d}{2} + 1\right)} \right] \nonumber \\
&= \frac{1}{2}\lim_{(c,d)\rightarrow (1,0)} \Gamma\left(\frac{d + 1}{2}\right)\left[\frac{\Gamma^{'}\left( \frac{c + 1}{2}\right)\cdot \frac{1}{2}}{\Gamma\left( \frac{c + d}{2} + 1\right)} -\frac{\Gamma\left( \frac{c + 1}{2}\right) \Gamma^{'}\left( \frac{c + d}{2} + 1\right) \cdot \frac{1}{2}}{\Gamma^2\left( \frac{c + d}{2} + 1\right)}  \right] \nonumber \\
&= \frac{1}{4}\Gamma\left( \frac{1}{2}\right)\left[ \frac{\Gamma^{'}\left(\frac{1}{2} \right)}{\Gamma\left(\frac{3}{2}\right)} - \frac{\Gamma\left(\frac{1}{2}\right)\Gamma^{'}\left(\frac{3}{2}\right)}{\Gamma^2\left(\frac{3}{2}\right)} \right]
\end{align}
Now:
\begin{equation}
\Gamma\left(\frac{1}{2} \right) = \sqrt{\pi}, \quad \Gamma\left(\frac{3}{2} \right) = \frac{\sqrt{\pi}}{2} \quad \Gamma^{'}\left(\frac{1}{2} \right) = \sqrt{\pi}\left( - \gamma - 2\ln(2)\right),\quad \Gamma^{'}\left(\frac{3}{2} \right) = \frac{\sqrt{\pi}}{2}\left(2 - \gamma - 2\ln(2)\right)
\end{equation}
Thus, 
\begin{align}
 I & \frac{1}{4} \cdot \sqrt{\pi}\left[\frac{\sqrt{\pi}\left( - \gamma - 2\ln(2)\right)}{\frac{\sqrt{\pi}}{2}} - \frac{\sqrt{\pi} \cdot \frac{\sqrt{\pi}}{2}\left(2 - \gamma - 2\ln(2)\right)}{\left(\frac{\sqrt{\pi}}{2} \right)^2}\right] \nonumber \\
& = \ln(2) - 1 = \ln\left(\frac{2}{e}\right)
\end{align}
</s>