How can I include SessionID in log files using log4net in ASP.NET?

后端 未结 5 746
执念已碎
执念已碎 2020-12-25 13:00

I\'m new to log4net, so hopefully this is a really easy question for someone?!

I\'ve got log4net working with the RollingLogFileAppender for my web application. I\'

5条回答
  •  佛祖请我去吃肉
    2020-12-25 13:25

    You can try:

    
    

    ...in your Web.config, and in Global.asax.cs:

    protected void Session_Start(object sender, EventArgs e)
    {
        log4net.ThreadContext.Properties["SessionID"] = Session.SessionID;
        log4net.Config.XmlConfigurator.Configure();
    }
    

提交回复
热议问题