Append current Date to Log file with Log4Net

前端 未结 5 649
忘掉有多难
忘掉有多难 2020-12-30 07:26

All I want to do is append the current date and time to my log file, say:

\"export_(Wed_Feb_21_2009_at_1_36_41PM)\"

Here is my current conf

5条回答
  •  自闭症患者
    2020-12-30 08:14

    If you want to use a .log suffix (to generate a file like myLogPrefix.20160309.log) use:

    
            
            
            
            
            
            
            
                
            
    
    

    The gotchas are the staticLogFileName = false which allows you to generate rollups on the fly (instead of having to restart the service\server) and the awkward 'g' in the datepattern since g is a magic character in datePattern. There isn't good documentation on the log4net site to study this, so it's really wisdom gained from trial and error and scouring other people's experiences.

提交回复
热议问题