-1

I've got a custom WcfAppender used by various projects (wpf, web etc). I want to log the username, however different technologies are used by the projects (windows authentication, federated security etc) and I don't want to write tightly coupled code, to the specific authentication technology. Can I somehow tell the appender how to find the username, by setting an action or similar? What are best practices in regards to custom log4net appenders?

svick
  • 236,525
  • 50
  • 385
  • 514
jaspernygaard
  • 3,098
  • 5
  • 35
  • 52

1 Answers1

0

I asked a similar question about a year ago but I"m not sure that there is a great solution other than using ThreadContext and setting a variable that stores the username on every single wcf call like this:

//You would need to get currentUserLoggedIn 
log4net.ThreadContext.Properties["user"] = currentUserLoggedIn;

Here is my old question and there is an answer but this solution didn't work for me. Maybe it will for you:

log4net using ThreadContext.Properties in wcf PerSession service

Community
  • 1
  • 1
Cole W
  • 15,123
  • 6
  • 51
  • 85