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?
Asked
Active
Viewed 255 times
1 Answers
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