A systematic perturbation theory is developed for the ESR shift and is applied to the spin-1/2 Heisenberg antiferromagnetic chain with a general anisotropic exchange interaction. Using the Bethe ansatz technique, the resonance shift is obtained exactly for the whole range of temperature and magnetic field in the first order of the anisotropy. The obtained g shift strongly depends on magnetic fields at low temperature, showing a significant deviation from the previous classical result.