One logfile per run with log4j

后端 未结 4 1223
梦谈多话
梦谈多话 2020-12-03 11:26

How do you configure log4j.properties to have exactly one logfile per run of an app. I\'ve read that you should use a timestamp in the filename but that will create many fil

4条回答
  •  醉梦人生
    2020-12-03 11:57

    To start a new log file on app startup you may want to use OnStartupTriggeringPolicy

    Triggering Policies

    Example of XML config:

    
    
        
            C:/Logs/
        
        
            
                
                    
                
            
            
                
                    %d{dd/MM/yyyy HH:mm:ss} [%-5p/%t]: %C{1}(%L): %m%n
                
                
                    
                    
                
                
            
        
        
            
                
                
            
            
                
            
        
    
    

    Works well for me

提交回复
热议问题