Class FileAppender<E>

All Implemented Interfaces:
Appender<E>, ContextAware, FilterAttachable<E>, LifeCycle
Direct Known Subclasses:

public class FileAppender<E> extends OutputStreamAppender<E>
FileAppender appends log events to a file. For more information about this appender, please refer to the online manual at
Ceki Gülcü
  • Field Details

  • Constructor Details

  • Method Details

    • setFile

      public void setFile(String file)
      The File property takes a string value which should be the name of the file to append to.
    • isAppend

      public boolean isAppend()
      Returns the value of the Append property.
    • rawFileProperty

      public final String rawFileProperty()
      This method is used by derived classes to obtain the raw file property. Regular users should not be calling this method.
      the value of the file property
    • getFile

      public String getFile()
      Returns the value of the File property.

      This method may be overridden by derived classes.

    • start

      public void start()
      If the value of File is not null, then openFile(java.lang.String) is called with the values of File and Append properties.
      Specified by:
      start in interface LifeCycle
      start in class OutputStreamAppender<E>
    • stop

      public void stop()
      Description copied from class: OutputStreamAppender
      Stop this appender instance. The underlying stream or writer is also closed.

      Stopped appenders cannot be reused.

      Specified by:
      stop in interface LifeCycle
      stop in class OutputStreamAppender<E>
    • checkForFileCollisionInPreviousFileAppenders

    • addErrorForCollision

      protected void addErrorForCollision(String optionName, String optionValue, String appenderName)
    • openFile

      public void openFile(String file_name) throws IOException

      Sets and opens the file where the log output will go. The specified file must be writable.

      If there was already an opened file, then the previous file is closed first.

      Do not use this method directly. To configure a FileAppender or one of its subclasses, set its properties one by one and then call start().

      file_name - The path to the log file.
    • isPrudent

      public boolean isPrudent()
      true if in prudent mode
      See Also:
    • setPrudent

      public void setPrudent(boolean prudent)
      When prudent is set to true, file appenders from multiple JVMs can safely write to the same file.
      prudent -
    • setAppend

      public void setAppend(boolean append)
    • setBufferSize

      public void setBufferSize(FileSize bufferSize)
    • writeOut

      protected void writeOut(E event) throws IOException
      writeOut in class OutputStreamAppender<E>