0

I've got a basic ASP.NET webapp that uses log4net to keep track of certain key actions. When I'm running the app on my workstation, the log entries include my username:

[2012-08-15 18:05:17,838] - MoneyApp.Import - LocalAD\ivravenger - Attempting File Import From C:\fakepath\outputFile.txt

However, when I run the app on a server, I get the ASP.NET worker process as the user ID:

[2012-08-15 18:05:17,838] - MoneyApp.Import - IIS APPPOOL\ASP.NET v4.0 32-bit - Attempting File Import From C:\fakepath\outputFile.txt

Here's my config string:

<conversionPattern value="[%date] - %logger - %username - %message%newline" />

How do I go about getting the web user ID into the log file? I'm already retrieving the user ID within the codebehind on each page, I'm just not sure the best way to get it into the log text without having to append it to each log() statement.

IVR Avenger
  • 15,090
  • 13
  • 46
  • 57
  • Try this http://stackoverflow.com/questions/4813242/capture-username-with-log4net – Cole W Aug 21 '12 at 01:20
  • 1
    or this may be better: http://stackoverflow.com/questions/938361/use-the-asp-net-request-user-for-log4net-log-entries – Cole W Aug 21 '12 at 01:21
  • Perfect! That did the trick: http://stackoverflow.com/questions/938361/use-the-asp-net-request-user-for-log4net-log-entries – IVR Avenger Aug 30 '12 at 14:51

0 Answers0