org.apache.log.output.io
Class SafeFileTarget

java.lang.Object
  extended byorg.apache.log.output.AbstractTarget
      extended byorg.apache.log.output.AbstractOutputTarget
          extended byorg.apache.log.output.io.StreamTarget
              extended byorg.apache.log.output.io.FileTarget
                  extended byorg.apache.log.output.io.SafeFileTarget
All Implemented Interfaces:
Closeable, ErrorAware, LogTarget

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
SafeFileTarget(java.io.File file, boolean append, Formatter formatter)
          Construct file target to write to a file with a formatter.
 
Method Summary
 void 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SafeFileTarget

public SafeFileTarget(java.io.File file,
                      boolean append,
                      Formatter formatter)
               throws java.io.IOException
Construct file target to write to a file with a formatter.

Parameters:
file - the file to write to
append - true if file is to be appended to, false otherwise
formatter - 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:
processEvent in interface LogTarget
Overrides:
processEvent in class AbstractTarget
Parameters:
event - the log event


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.