  The charge degree of freedom in solid-state defects fundamentally underpins
the electronic spin degree of freedom, a workhorse of quantum technologies.
Here we study charge state properties of individual near-surface
nitrogen-vacancy (NV) centers in diamond, where NV$^{-}$ hosts the
metrologically relevant electron spin. We find that NV$^{-}$ initialization
fidelity varies between individual centers and over time, and we alleviate the
deleterious effects of reduced NV$^{-}$ initialization fidelity via logic-based
initialization. We also find that NV$^{-}$ can ionize in the dark, which
compromises spin measurements but is mitigated by measurement protocols we
present here. We identify tunneling to a single, local electron trap as the
mechanism for ionization in the dark and we develop NV-assisted techniques to
control and readout the trap charge state. Our understanding and command of the
NV's local electrostatic environment will simultaneously guide materials design
and provide novel functionalities with NV centers.
