Rolling logback logs on filesize and time

后端 未结 3 2183
无人及你
无人及你 2020-11-29 00:04

I\'ve been trying to set up a simple logback project to roll my log files by date and by filesize, and so far I have been unable to get my appender to roll over to another f

3条回答
  •  失恋的感觉
    2020-11-29 00:47

    Although this is an old question, I felt that a working answer is appropriate to help anyone who requires this kind of implementation.

    I use the following logback configuration to provide an HTML log, rolled over by date and filesize, as well as logging to console for debugging output.

    Logfiles are stored in a logs directory with a name of logFile.html while its active, and logFile.2013-mm-dd.i.html when it rolls over, where i is the number of 50MB log files. For instance logFile.2013-01-07.0.html.

    
    
      
        
        
          UTF-8
          %d{HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{35}) - %msg %n
        
      
    
      
        logs\logFile.html
        
          
          logs\logFile.%d{yyyy-MM-dd}.%i.html
          
              
            50MB
          
          
          30
        
        
          UTF-8
          
            %d{HH:mm:ss.SSS}%thread%level%logger%line%msg
                   
        
       
    
      
        
             
      
    
    
    

提交回复
热议问题