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
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
ConstructorsConstructorDescriptionSafeFileTarget
(File file, boolean append, Formatter formatter) Construct file target to write to a file with a formatter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
processEvent
(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 Details
-
SafeFileTarget
Construct 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:
IOException
- if an error occurs
-
-
Method Details
-
processEvent
Process a log event, via formatting and outputting it.- Specified by:
processEvent
in interfaceLogTarget
- Overrides:
processEvent
in classAbstractTarget
- Parameters:
event
- the log event
-