Class RotatingFileTarget
java.lang.Object
org.apache.log.output.AbstractTarget
org.apache.log.output.AbstractOutputTarget
org.apache.log.output.io.StreamTarget
org.apache.log.output.io.FileTarget
org.apache.log.output.io.rotate.RotatingFileTarget
- All Implemented Interfaces:
ErrorAware, LogTarget, Closeable
This is a basic Output log target that writes to rotating files.
- Author:
- Peter Donald, Stephen McConnell, Bernhard Huber
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanFlag indicating whether or not file should be appended toprivate FileStrategyThe file strategy to be used.private RotateStrategyThe rotation strategy to be used. -
Constructor Summary
ConstructorsConstructorDescriptionRotatingFileTarget(boolean append, Formatter formatter, RotateStrategy rotateStrategy, FileStrategy fileStrategy) Construct RotatingFileTarget object.RotatingFileTarget(Formatter formatter, RotateStrategy rotateStrategy, FileStrategy fileStrategy) Construct RotatingFileTarget object. -
Method Summary
Methods inherited from class FileTarget
getFile, openFile, setFileMethods inherited from class StreamTarget
close, setOutputStream, shutdownStreamMethods inherited from class AbstractOutputTarget
doProcessEvent, getFormatter, openMethods inherited from class AbstractTarget
getErrorHandler, isOpen, processEvent, setErrorHandler
-
Field Details
-
m_append
private boolean m_appendFlag indicating whether or not file should be appended to -
m_rotateStrategy
The rotation strategy to be used. -
m_fileStrategy
The file strategy to be used.
-
-
Constructor Details
-
RotatingFileTarget
public RotatingFileTarget(Formatter formatter, RotateStrategy rotateStrategy, FileStrategy fileStrategy) throws IOException Construct RotatingFileTarget object.- Parameters:
formatter- Formatter to be usedrotateStrategy- RotateStrategy to be usedfileStrategy- FileStrategy to be used- Throws:
IOException- if a file access or write related error occurs
-
RotatingFileTarget
public RotatingFileTarget(boolean append, Formatter formatter, RotateStrategy rotateStrategy, FileStrategy fileStrategy) throws IOException Construct RotatingFileTarget object.- Parameters:
append- true if file is to be appended to, false otherwiseformatter- Formatter to be usedrotateStrategy- RotateStrategy to be usedfileStrategy- FileStrategy to be used- Throws:
IOException- if a file access or write related error occurs
-
-
Method Details
-
rotate
Rotates the file.- Throws:
IOException- if a file access or write related error occurs
-
write
Output the log message, and check if rotation is needed.- Overrides:
writein classStreamTarget- Parameters:
data- the date to write to the target
-