It is impossible to configure logging of the #fragment portion of the URL because your web server never sees it. From RFC3986
the fragment identifier is separated from the rest of the URI prior to a dereference, and thus the identifying information within the fragment itself is dereferenced solely by the user agent, regardless of the URI scheme. Although this separate handling is often perceived to be a loss of information, particularly for accurate redirection of references as resources move over time, it also serves to prevent information providers from denying reference authors the right to refer to information within a resource selectively. Indirect referencing also provides additional flexibility and extensibility to systems that use URIs, as new media types are easier to define and deploy than new schemes of identification.
What this means is that the web browser basically strips off the anchor part of the URI before sending it to the web server. The HTTP protocol doesn't even deal with fragments because of this; they're never sent over the wire.
Once you've done this, it can be logged using AJAX or, as pelms notes, passed to Google Analytics or similar services.