We derive a full formula for the energy level of a heavy quarkonium state identified by the quantum numbers n, ℓ, s and j, up to O(αs5m) and O(αs5mlogαs) in perturbative QCD. The QCD Bethe logarithm is given in a one-parameter integral form. The rest of the formula is given as a combination of rational numbers, transcendental numbers (π, ζ(3), ζ(5)) and finite sums (besides the 3-loop constant a¯3 of the static potential whose full analytic form is still unknown). A derivation of the formula is given.