View Javadoc
1   package ch.qos.logback.core.rolling;
2   
3   import ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP.Usage;
4   import ch.qos.logback.core.util.FileSize;
5   
6   
7   
8   public class SizeAndTimeBasedRollingPolicy<E> extends TimeBasedRollingPolicy<E> {
9   
10      FileSize maxFileSize;
11      
12      @Override
13      public void start() {
14          SizeAndTimeBasedFNATP<E> sizeAndTimeBasedFNATP = new SizeAndTimeBasedFNATP<E>(Usage.EMBEDDED); 
15          if(maxFileSize == null) {
16              addError("maxFileSize property is mandatory.");
17              return;
18          } else {
19              addInfo("Archive files will be limited to ["+maxFileSize+"] each.");
20          }
21          
22          sizeAndTimeBasedFNATP.setMaxFileSize(maxFileSize);
23          timeBasedFileNamingAndTriggeringPolicy = sizeAndTimeBasedFNATP;
24          
25          if(!isUnboundedTotalSizeCap() && totalSizeCap.getSize() < maxFileSize.getSize()) {
26              addError("totalSizeCap of ["+totalSizeCap+"] is smaller than maxFileSize ["+maxFileSize+"] which is non-sensical");
27              return;
28          }
29          
30          // most work is done by the parent
31          super.start();
32      }
33      
34      
35      public void setMaxFileSize(FileSize aMaxFileSize) {
36          this.maxFileSize = aMaxFileSize;
37      }
38      
39      @Override
40      public String toString() {
41          return "c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@"+this.hashCode();
42      }
43  }