Having a log per day

后端 未结 3 1660
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 13:20

Currently my application is using log4net to log errors, the web.config for this is as followed:

 
            


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-08 13:48

    You should use RollingFileAppender with rollingStyle Date and datePattern yyyyMMdd (this will roll every day).

    Example of configuration:

    
        
        
        
        
        
            
        
    
    

    UPDATE: I think a better way is to include the date into file name. And use datePattern value only to show when new log file should be created.

    
      
      
      
      
      
        
      
    
    

    In this case all your files will have name like gateway_20120427.log.

提交回复
热议问题