Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, QOS.ch. All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
 
 package ch.qos.logback.core.rolling;
 
 import java.io.File;
 
SizeBasedTriggeringPolicy looks at size of the file being currently written to. If it grows bigger than the specified size, the FileAppender using the SizeBasedTriggeringPolicy rolls the file and creates a new one. For more information about this policy, please refer to the online manual at http://logback.qos.ch/manual/appenders.html#SizeBasedTriggeringPolicy

Author(s):
Ceki Gülcü
 
 public class SizeBasedTriggeringPolicy<E> extends TriggeringPolicyBase<E> {
 
   public static final String SEE_SIZE_FORMAT = "http://logback.qos.ch/codes.html#sbtp_size_format";
  
The default maximum file size.
 
   public static final long DEFAULT_MAX_FILE_SIZE = 10 * 1024 * 1024; // 10 MB
 
 
   public SizeBasedTriggeringPolicy() {
   }
 
   public SizeBasedTriggeringPolicy(final String maxFileSize) {
     setMaxFileSize(maxFileSize);
   }
 
   private InvocationGate invocationGate = new InvocationGate();
 
   public boolean isTriggeringEvent(final File activeFilefinal E event) {
       return false;
 
     long now = System.currentTimeMillis();
 
     return (activeFile.length() >= .getSize());
   }
 
   public String getMaxFileSize() {
     return ;
   }
 
   public void setMaxFileSize(String maxFileSize) {
     this. = maxFileSize;
     this. = FileSize.valueOf(maxFileSize);
   }
 
   long toFileSize(String value) {
     if (value == null)
       return ;
 
     String s = value.trim().toUpperCase();
     long multiplier = 1;
     int index;
 
     if ((index = s.indexOf("KB")) != -1) {
       multiplier = 1024;
       s = s.substring(0, index);
     } else if ((index = s.indexOf("MB")) != -1) {
       multiplier = 1024 * 1024;
       s = s.substring(0, index);
     } else if ((index = s.indexOf("GB")) != -1) {
       multiplier = 1024 * 1024 * 1024;
       s = s.substring(0, index);
     }
     if (s != null) {
       try {
         return Long.valueOf(s).longValue() * multiplier;
       } catch (NumberFormatException e) {
         addError("[" + s + "] is not in proper int format. Please refer to "
             + );
         addError("[" + value + "] not in expected format."e);
       }
     }
     return ;
   }
New to GrepCode? Check out our FAQ X