Is there a similar formula like the Stirling one on the sum over $\ln(n)$ (take logarithms on its factorial representation):
$$\sum_{n=1}^N \ln(n) = N \ln(N)-N+\ln(N)/2+\ln(2\pi)/2+\mathcal{O}(\ln(N)/N)$$
but on the sum over its squares?
$$\sum_{n=1}^N (\ln(n))^2$$
I already advanced on getting good approximation on asymptotics integrating $\ln(n)^2$ and arrive to correct terms till $\mathcal{O}(N)$ order. But further advance is becoming hard for me in $\mathcal{O}(\ln(N))$ terms.
I am specially interested in $\mathcal{O}(1)$ term.
I've encountered an exercise recently which gives an asymptotic formula $$ \sum_1^N \log^2(n)= \left( n +\frac 12\right)\log^2(n) -2n \log(n) +2n + C + r_n \quad [r_n \to 0, C \text{a constant}]. $$ Hope this could help.
The derivation TBA...