Capture username with log4net

后端 未结 6 1260
忘了有多久
忘了有多久 2020-11-27 17:05

I currently write all log4net events to a database, and it seems to work just fine. To capture the logged in user account I use this piece of code:

HttpConte         


        
6条回答
  •  再見小時候
    2020-11-27 17:34

    I've used the solution of wageoghe and Gian Marco Gherardi, but rather than GlobalContext have set the thread context immediatley before logging the message:

    ThreadContext.Properties["user"] = new HttpContextUserNameProvider();
    

提交回复
热议问题