Can't get Log4Net to work in my ASP.NET website :(

后端 未结 5 1441
终归单人心
终归单人心 2021-02-10 13:22

really simple question -> i can\'t seem to get any data from Log4Net in my ASP.NET application. I\'ve got a simple ASP.NET website, which references a class library. In this cla

5条回答
  •  独厮守ぢ
    2021-02-10 14:13

    I had this same problem and I think it was looking at the wrong web.config or something. I finally separated out log4net.config from web.config and put a path to it \inetpub\Logs\log4net.config and all is well.

    UDPATED ON REQUEST: edited from a slightly more complicated version.

    
    
        
            
                
            
        \
    
        
            
            
            
        
    
    

    And it is configured in code as follows:

            var logpath = WebConfigurationManager.AppSettings["LogConfigPath"] ?? @"\Inetpub\Logs\log4net.config";
            var finfo = new System.IO.FileInfo ( logpath );
            XmlConfigurator.Configure( finfo );
    

提交回复
热议问题