$$\log \Gamma (n)=n\log n -n +\frac{1}{2} \log \frac{2\pi}{n}+\int_0^\infty \frac{2\arctan (\frac{x}{n})}{e^{2\pi x}-1} \,\mathrm{d}x$$
Is an identity that is derived from using Sterling's approximation. I can't quite figure out how it was used, and was wondering for a proof.
Differentiate the integral $I(n)=2 \int_0^{\infty}\frac{\arctan(x/n)}{e^{2\pi t}-1}$ w.r.t. $n$:
$$ I'(n)=\frac{2}{n} \int_{0}^{\infty}\frac{(x/n)}{(x/n)^2+1}\frac{1}{e^{2\pi x}-1}=\frac{-i}{n}\int_0^{\infty}\frac{f(i (x/n))-f(-i (x/n))}{e^{2\pi x}-1} $$
with $f(x/n)=\frac{1}{1+(x/n)}$
Let's apply Abel-Plana:
$$ I'(n)=-\lim_{N\rightarrow \infty}\left(\sum_{m=0}^{N}\frac{1}{n+m}-\log(N)\right)+\frac{1}{2n}-\log(n) $$
The limit is given by the Digamma function and therefore
integrating back w.r.t $n$ gives
$$ I(n)=\log(\Gamma(n))+\frac{\log(n)}{2}-n(\log(n)-1)+C $$
To fix the constant of integration we observe that $I(\infty)=0$. Together with the asymptotic expansion $\log(\Gamma(z))\approx \log(\sqrt{2\pi z}\left(\frac{z}{e}\right)^z)=(z-1/2)\log(z)-z+\frac{1}{2}\log(2\pi)$ this yields $C=-\frac{1}{2}\log(2\pi)$
We obtain:
this differs from the proposed answer by some signs in subleading terms, but is the same then as here
Appendix
Theorem:
(Informal) Proof:
Let's use the classical (Gauss-) product representation of the Gamma function:
$$\Gamma(x)=\lim_{N\rightarrow \infty}\frac{N! N^x}{\prod_{m=0}^N (x+m)}$$
taking logarithms
$$ \log(\Gamma(x))=\lim_{N\rightarrow \infty}( \log(N!)+x\log(N)-\sum_{m=0}^N\log(x+m)) $$
differentiate w.r.t. $x$
$$ \psi(x)\equiv\partial_x\log(\Gamma(x))=\lim_{N\rightarrow \infty}(\log(N)-\sum_{m=0}^N\frac{1}{x+m}) $$