A $\log \Gamma $ identity: Where does it come from? $$\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.
 A: 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

$$
I'(n)=\psi(n)+\frac{1}{2n}-\log(n)
$$

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:

$$
I(n)=\log(\Gamma(n))+\frac{\log(n)}{2}-n(\log(n)-1)-\frac{1}{2}\log(2\pi)
$$

this differs from the proposed answer by some signs in subleading terms, but is the same then as here
Appendix
Theorem:

The Digamma function is given by $\psi(x)=\lim_{N\rightarrow \infty}\left(-\sum_{m=0}^{N}\frac{1}{x+m}+\log(N)\right)$

(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})
$$

QED

A: 
Proposition : $$\int_{0}^{\infty} \dfrac{\log(1-e^{-2a\pi x})}{1+x^2} \mathrm{d}x = \pi \left[\dfrac{1}{2} \log (2a\pi ) + a(\log a - 1) - \log(\Gamma(a+1)) \right]$$     

Proof : Let $ \displaystyle \text{I} (a) = \int_{0}^{\infty} \dfrac{\log(1-e^{-2a\pi x})}{1+x^2} \mathrm{d}x$  
$\displaystyle  = -\sum_{r=1}^{\infty} \dfrac{1}{r} \int_{0}^{\infty} \dfrac{e^{-2ar \pi x}}{1+x^2} \mathrm{d}x $  
$\displaystyle  = -\sum_{r=1}^{\infty} \dfrac{1}{r} \int_{0}^{\infty} \int_{0}^{\infty} e^{-x(2ar \pi + y)} \sin y \ \mathrm{d}y \ \mathrm{d}x $  
$\displaystyle  = -\sum_{r=1}^{\infty} \dfrac{1}{r} \int_{0}^{\infty} \dfrac{\sin y}{2ar\pi + y} \mathrm{d}y $  
$\displaystyle  = - \sum_{r=1}^{\infty} \dfrac{1}{r} \int_{0}^{\infty} \dfrac{\sin x}{2ar\pi + x} \mathrm{d}x$  
Substitute $\displaystyle  x \mapsto 2 r \pi x$  
$\displaystyle \implies \text{I}(a)  = - \sum_{r=1}^{\infty} \dfrac{1}{r} \int_{0}^{\infty} \dfrac{\sin 2 r \pi x}{x + a} \mathrm{d}x $  
$\displaystyle  = -\int_{0}^{\infty} \dfrac{1}{x+a} \sum_{r=1}^{\infty} \dfrac{\sin(2 r \pi x)}{r} \mathrm{d}x $  
$\displaystyle  = -\pi \int_{0}^{\infty} \dfrac{1}{x+a} \left(\dfrac{1}{2} - \{x\} \right) \mathrm{d}x \quad \left( \because \sum_{r=1}^{\infty} \dfrac{\sin (2 r \pi x)}{r} = \dfrac{\pi}{2} - \pi \{x\} \right) $  
$\displaystyle = -\pi \left[ \int_{0}^{\infty} \dfrac{\mathrm{d}x}{2(x+a)} - \int_{0}^{\infty} \dfrac{\{x\}}{x+a} \mathrm{d}x \right] $  
$\displaystyle  = -\pi \lim_{n \to \infty} \left[ \dfrac{1}{2} \log \left(\dfrac{a+n}{a}\right) - \text{A}(n) \right]$  
where $\displaystyle  \text{A}(n) = \int_{0}^{n} \dfrac{\{x\} }{x+a} \mathrm{d}x$   
Now, 
$\displaystyle \text{A}(n) = \int_{0}^{n} \dfrac{\{x\} }{x+a} \mathrm{d}x $  
$\displaystyle  = \sum_{k=0}^{n} \int_{k}^{k+1} \dfrac{x-k}{x+a} \mathrm{d}x $    
$\displaystyle  = \sum_{k=0}^{n} \left[1 - (k+a)\log \left(\dfrac{k+a+1}{k+a}\right) \right] $  
$\displaystyle  = n - \sum_{k=0}^{n} \left[ (k+a+1) \log (k+a+1) - (k+a) \log (k+a) - \log (k+a+1) \right] $     
$\displaystyle  = n + a\log a - (a+n) \log (a+n) +\log(a \cdot (a+1) \cdot \ldots \cdot (a+n)) - \log a $    
$\displaystyle  \implies \text{I} (a) = -\pi \lim_{n \to \infty} \left[ \dfrac{1}{2} \log \left(\dfrac{a+n}{a}\right) - n - a\log a + (a+n) \log (a+n) - \log(a \cdot (a+1) \cdot \ldots \cdot (a+n)) + \log a  \right] $    
Note that $\displaystyle  \lim_{n \to \infty} \dfrac{ n! n^t}{t \cdot (t+1) \cdot \ldots \cdot (t+n)} = \Gamma(t) $    
$\displaystyle  \implies \text{I} (a) = -\pi \lim_{n \to \infty}  \left[ \dfrac{1}{2} \log \left(\dfrac{a+n}{a}\right) - n - a\log a + (a+n) \log (a+n) - a\log(n) - \log (n!) + \log(\Gamma(a)) + \log a  \right] $  
Simplifying using Stirling's Approximation and $\displaystyle  \lim_{n \to \infty } n \log \left(1 + \dfrac{a}{n} \right) = a $, we have,  
$\displaystyle  \text{I} (a) = -\pi \left[\log(\Gamma(a+1)) - \dfrac{1}{2} \log(2a \pi) - a (\log(a) -1) \right]  $  
$\displaystyle  = \pi \left[ \dfrac{1}{2} \log(2a \pi) + a (\log(a) -1) - \log(\Gamma(a+1)) \right] \quad \square $   
Now, 
Applying Integration By Parts on the proposition and simplifying, we get,  
$ \displaystyle \int_{0}^{\infty} \tan^{-1} \left(\dfrac{t}{a}\right)\dfrac{\mathrm{d}t}{e^{2\pi t} - 1} = \dfrac{1}{2} \left[ \log(\Gamma(a)) - \dfrac{\log(2a)}{2} - \left( a - \dfrac{1}{2} \right)\log (a) +a\right]  $    
$$\therefore \log(\Gamma(a)) = 2\int_{0}^{\infty} \tan^{-1} \left(\dfrac{t}{a}\right)\dfrac{\mathrm{d}t}{e^{2\pi t} - 1} + \dfrac{\log(2a)}{2} + \left( a - \dfrac{1}{2} \right)\log (a) -a \quad \square $$
