Package org.apache.log.output.io
Class SafeFileTarget
- 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.SafeFileTarget
-
- All Implemented Interfaces:
ErrorAware,LogTarget,Closeable
public class SafeFileTarget extends FileTarget
A target that will open and close a file for each logevent. This is slow but a more reliable form of logging on some filesystems/OSes. It should only be used when there is a small number of log events.- Author:
- Peter Donald
-
-
Constructor Summary
Constructors Constructor Description SafeFileTarget(java.io.File file, boolean append, Formatter formatter)Construct file target to write to a file with a formatter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidprocessEvent(LogEvent event)Process a log event, via formatting and outputting it.-
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, write
-
Methods inherited from class org.apache.log.output.AbstractOutputTarget
doProcessEvent, getFormatter, open
-
Methods inherited from class org.apache.log.output.AbstractTarget
getErrorHandler, isOpen, setErrorHandler
-
-
-
-
Constructor Detail
-
SafeFileTarget
public SafeFileTarget(java.io.File file, boolean append, Formatter formatter) throws java.io.IOExceptionConstruct file target to write to a file with a formatter.- Parameters:
file- the file to write toappend- true if file is to be appended to, false otherwiseformatter- the Formatter- Throws:
java.io.IOException- if an error occurs
-
-
Method Detail
-
processEvent
public void processEvent(LogEvent event)
Process a log event, via formatting and outputting it.- Specified by:
processEventin interfaceLogTarget- Overrides:
processEventin classAbstractTarget- Parameters:
event- the log event
-
-