Class SafeFileTarget

  extended byorg.apache.log.output.AbstractTarget
      extended byorg.apache.log.output.AbstractOutputTarget
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.

Peter Donald

Constructor Summary
SafeFileTarget( 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
getFile, openFile, setFile
Methods inherited from class
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


public SafeFileTarget( file,
                      boolean append,
                      Formatter formatter)
Construct file target to write to a file with a formatter.

file - the file to write to
append - true if file is to be appended to, false otherwise
formatter - the Formatter
Throws: - if an error occurs
Method Detail


public void processEvent(LogEvent event)
Process a log event, via formatting and outputting it.

Specified by:
processEvent in interface LogTarget
processEvent in class AbstractTarget
event - the log event

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