org.x4juli.handlers.rolling
Class SizeBasedTriggeringPolicy

java.lang.Object
  extended byorg.x4juli.global.components.AbstractComponent
      extended byorg.x4juli.handlers.rolling.SizeBasedTriggeringPolicy
All Implemented Interfaces:
Component, OptionHandler, TriggeringPolicy

public class SizeBasedTriggeringPolicy
extends AbstractComponent
implements TriggeringPolicy, OptionHandler

SizeBasedTriggeringPolicy looks at size of the file being currently written to.

Logging API as a whole was originally done for Apache log4j. Juli is a port of main parts of that to complete the Java Logging APIs. All credits for initial idea, design, implementation, documentation belong to the log4j crew. This file was originally published by Ceki Gülcü, Curt Arnold. Please use exclusively the appropriate mailing lists for questions, remarks and contribution.

Since:
0.5
Author:
Boris Unckel

Field Summary
private static long DEFAULT_MAX_FILE_SIZE
          Rollover threshold size in bytes.
private  long maxFileSize
           
 
Fields inherited from class org.x4juli.global.components.AbstractComponent
manager, repository
 
Constructor Summary
SizeBasedTriggeringPolicy()
          Constructor for use with file based configuration.
SizeBasedTriggeringPolicy(long maxFileSize)
          Constructor for use in programmatically configuration.
 
Method Summary
 void activateOptions()
          Activate the options that were previously set with calls to option setters.

This allows to defer activiation of the options until all options have been set. This is required for components which have related options that remain ambigous until all are set.

 void configure()
          Configure all properties of the object.
 long getMaxFileSize()
          Gets rollover threshold size in bytes.
 boolean isTriggeringEvent(java.util.logging.Handler handler, ExtendedLogRecord record, java.lang.String filename, long fileLength)
          Determines if a rollover may be appropriate at this time. If true is returned, RolloverPolicy.rollover will be called but it can determine that a rollover is not warranted.
 void setMaxFileSize(long l)
          Sets rollover threshold size in bytes.
 
Methods inherited from class org.x4juli.global.components.AbstractComponent
getLogger, getLoggerRepository, getMessageProperties, getNonFloodingLogger, getProperty, getProperty, getProperty, getProperty, resetErrorCount, setObjectStore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_FILE_SIZE

private static final long DEFAULT_MAX_FILE_SIZE
Rollover threshold size in bytes.

See Also:
Constant Field Values

maxFileSize

private long maxFileSize
Constructor Detail

SizeBasedTriggeringPolicy

public SizeBasedTriggeringPolicy()
Constructor for use with file based configuration.


SizeBasedTriggeringPolicy

public SizeBasedTriggeringPolicy(long maxFileSize)
Constructor for use in programmatically configuration.

Parameters:
maxFileSize - rollover threshold size in bytes.
Method Detail

isTriggeringEvent

public boolean isTriggeringEvent(java.util.logging.Handler handler,
                                 ExtendedLogRecord record,
                                 java.lang.String filename,
                                 long fileLength)
Determines if a rollover may be appropriate at this time. If true is returned, RolloverPolicy.rollover will be called but it can determine that a rollover is not warranted.

Specified by:
isTriggeringEvent in interface TriggeringPolicy
Parameters:
handler - A reference to the handler.
record - A reference to the current record.
filename - The filename for the currently active log file.
fileLength - Length of the file in bytes.
Returns:
true if a rollover should occur.
Since:
0.5

activateOptions

public void activateOptions()
Activate the options that were previously set with calls to option setters.

This allows to defer activiation of the options until all options have been set. This is required for components which have related options that remain ambigous until all are set.

Specified by:
activateOptions in interface OptionHandler
Since:
0.5

configure

public void configure()
Configure all properties of the object. Subclasses should call super.configure() to ensure proper configuration.

Since:
0.5

getMaxFileSize

public long getMaxFileSize()
Gets rollover threshold size in bytes.

Returns:
rollover threshold size in bytes.
Since:
0.5

setMaxFileSize

public void setMaxFileSize(long l)
Sets rollover threshold size in bytes.

Parameters:
l - new value for rollover threshold size.
Since:
0.5


${license_html}