Statistical thermodynamics
The only time I've ever seen that second notation is when referring to the substitution of the Helmholtz energy, as A = U-TS and therefore A = -kTlnQ. If you want an in depth explanation of how the thing is derived I suggest looking at Chapter 10 of Biomolecular Thermodynamics: From Theory to Application by Douglas E. Barrick. 

Here are some photos of the key parts: