My ASP.NET site is using Integrated Authentication with impersonation turned off. I have added a “%username” to my “conversionPattern” in the web.config to add the user name to each logging entry. However this will use the application pool identity’s user name, and not the current visiting user’s name.
Any ideas on how best to do this? Do I have to write a custom appender? I don’t mind any minor performance penalties as this is a small intranet site. Thanks!
An alternative (and easier) solution you may want to take a look at is to use the
ThreadContextclass (formerly implemented as theMDCandNDCclasses). You could have something like this inside anHttpModule(before the request arrives at your page) or anywhere else before you log your first message:And then include the following in your conversionPattern: