org.apache.log.output.io.rotate
Class RotatingFileTarget

java.lang.Object
  extended by org.apache.log.output.AbstractTarget
      extended by org.apache.log.output.AbstractOutputTarget
          extended by org.apache.log.output.io.StreamTarget
              extended by org.apache.log.output.io.FileTarget
                  extended by org.apache.log.output.io.rotate.RotatingFileTarget
All Implemented Interfaces:
ErrorAware, LogTarget, Closeable

public class RotatingFileTarget
extends FileTarget

This is a basic Output log target that writes to rotating files.

Author:
Peter Donald, Stephen McConnell, Bernhard Huber

Field Summary
private  boolean m_append
           
private  FileStrategy m_fileStrategy
           
private  RotateStrategy m_rotateStrategy
           
 
Constructor Summary
RotatingFileTarget(boolean append, Formatter formatter, RotateStrategy rotateStrategy, FileStrategy fileStrategy)
          Construct RotatingFileTarget object.
RotatingFileTarget(Formatter formatter, RotateStrategy rotateStrategy, FileStrategy fileStrategy)
          Construct RotatingFileTarget object.
 
Method Summary
protected  void rotate()
          Rotates the file.
protected  void write(java.lang.String data)
          Output the log message, and check if rotation is needed.
 
Methods inherited from class org.apache.log.output.io.FileTarget
getFile, openFile, setFile
 
Methods inherited from class org.apache.log.output.io.StreamTarget
close, setOutputStream, shutdownStream
 
Methods inherited from class org.apache.log.output.AbstractOutputTarget
doProcessEvent, getFormatter, open
 
Methods inherited from class org.apache.log.output.AbstractTarget
getErrorHandler, isOpen, processEvent, setErrorHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_append

private boolean m_append

m_rotateStrategy

private RotateStrategy m_rotateStrategy

m_fileStrategy

private FileStrategy m_fileStrategy
Constructor Detail

RotatingFileTarget

public RotatingFileTarget(Formatter formatter,
                          RotateStrategy rotateStrategy,
                          FileStrategy fileStrategy)
                   throws java.io.IOException
Construct RotatingFileTarget object.

Parameters:
formatter - Formatter to be used
rotateStrategy - RotateStrategy to be used
fileStrategy - FileStrategy to be used
Throws:
java.io.IOException - if a file access or write related error occurs

RotatingFileTarget

public RotatingFileTarget(boolean append,
                          Formatter formatter,
                          RotateStrategy rotateStrategy,
                          FileStrategy fileStrategy)
                   throws java.io.IOException
Construct RotatingFileTarget object.

Parameters:
append - true if file is to be appended to, false otherwise
formatter - Formatter to be used
rotateStrategy - RotateStrategy to be used
fileStrategy - FileStrategy to be used
Throws:
java.io.IOException - if a file access or write related error occurs
Method Detail

rotate

protected void rotate()
               throws java.io.IOException
Rotates the file.

Throws:
java.io.IOException - if a file access or write related error occurs

write

protected void write(java.lang.String data)
Output the log message, and check if rotation is needed.

Overrides:
write in class StreamTarget
Parameters:
data - the date to write to the target