How to control log file with daily rolling and max file size by log4j?

后端 未结 3 1416
情书的邮戳
情书的邮戳 2021-02-04 08:40

I would like to create log file that can be rolled at the beginning of the next day or if it\'s reached to specified file size and log file must be contained inside date folder.

3条回答
  •  感情败类
    2021-02-04 09:23

    To enable the daily rolling: class="org.apache.log4j.DailyRollingFileAppender"

    And to enable the max file size and the number of backup files

      
    
    

    But you can not put MaxFileSize with DailyRolling, so you can use rolling file appender

    An example:

    
        
        
        
        
          
        
        
            
        
    
    

    Or you can do this http://wiki.apache.org/logging-log4j/DailyRollingFileAppender

提交回复
热议问题