FileAppender Class Reference

Inheritance diagram for FileAppender:

Inheritance graph
[legend]
Collaboration diagram for FileAppender:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FileAppender ()
 FileAppender (const LayoutPtr &layout, const String &filename, bool append, bool bufferedIO, int bufferSize)
 FileAppender (const LayoutPtr &layout, const String &filename, bool append)
 FileAppender (const LayoutPtr &layout, const String &filename)
void setFile (const String &file)
void setFile (const String &file, bool append, bool bufferedIO, int bufferSize)
bool getAppend () const
const String & getFile () const
void activateOptions ()
void setOption (const String &option, const String &value)
bool getBufferedIO () const
int getBufferSize () const
void setAppend (bool fileAppend)
void setBufferedIO (bool bufferedIO)
void setBufferSize (int bufferSize)

Protected Member Functions

virtual void closeWriter ()
void closeFile ()

Protected Attributes

bool fileAppend
String fileName
bool bufferedIO
int bufferSize

Detailed Description

FileAppender appends log events to a file.

Support for java.io.Writer and console appending has been deprecated and then removed. See the replacement solutions: WriterAppender and ConsoleAppender.


Constructor & Destructor Documentation

FileAppender  ) 
 

The default constructor does not do anything.

FileAppender const LayoutPtr layout,
const String &  filename,
bool  append,
bool  bufferedIO,
int  bufferSize
 

Instantiate a FileAppender and open the file designated by filename. The opened filename will become the output destination for this appender.

If the append parameter is true, the file will be appended to. Otherwise, the file designated by filename will be truncated before being opened.

If the bufferedIO parameter is true, then buffered IO will be used to write to the output file.

FileAppender const LayoutPtr layout,
const String &  filename,
bool  append
 

Instantiate a FileAppender and open the file designated by filename. The opened filename will become the output destination for this appender.

If the append parameter is true, the file will be appended to. Otherwise, the file designated by filename will be truncated before being opened.

FileAppender const LayoutPtr layout,
const String &  filename
 

Instantiate a FileAppender and open the file designated by filename. The opened filename will become the output destination for this appender.

The file will be appended to.


Member Function Documentation

void activateOptions  )  [virtual]
 

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.

Reimplemented from AppenderSkeleton.

Reimplemented in DailyRollingFileAppender.

void closeFile  )  [protected]
 

Closes the previously opened file.

void closeWriter  )  [protected, virtual]
 

Closes the previously opened file.

Implements WriterAppender.

bool getAppend  )  const [inline]
 

Returns the value of the Append option.

bool getBufferedIO  )  const [inline]
 

Get the value of the BufferedIO option.

BufferedIO will significatnly increase performance on heavily loaded systems.

int getBufferSize  )  const [inline]
 

Get the size of the IO buffer.

const String& getFile  )  const [inline]
 

Returns the value of the File option.

void setAppend bool  fileAppend  )  [inline]
 

The Append option takes a boolean value. It is set to true by default. If true, then File will be opened in append mode by setFile (see above). Otherwise, setFile will open File in truncate mode.

Note: Actual opening of the file is made when activateOptions is called, not when the options are set.

void setBufferedIO bool  bufferedIO  ) 
 

The BufferedIO option takes a boolean value. It is set to false by default. If true, then File will be opened in buffered mode.

BufferedIO will significantly increase performance on heavily loaded systems.

void setBufferSize int  bufferSize  )  [inline]
 

Set the size of the IO buffer.

void setFile const String &  file,
bool  append,
bool  bufferedIO,
int  bufferSize
 

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 activateOptions.

Parameters:
file The path to the log file.
append If true will append to fileName. Otherwise will truncate fileName.
bufferedIO Do we do bufferedIO?
bufferSize How big should the IO buffer be?

void setFile const String &  file  ) 
 

The File property takes a string value which should be the name of the file to append to.

Note that the special values "System.out" or "System.err" are no longer honored.

Note: Actual opening of the file is made when activateOptions is called, not when the options are set.

void setOption const String &  option,
const String &  value
[virtual]
 

Set option to value.

The handling of each option depends on the OptionHandler instance. Some options may become active immediately whereas other may be activated only when activateOptions is called.

Reimplemented from AppenderSkeleton.

Reimplemented in DailyRollingFileAppender, and RollingFileAppender.


Member Data Documentation

bool bufferedIO [protected]
 

Do we do bufferedIO?

int bufferSize [protected]
 

How big should the IO buffer be? Default is 8K.

bool fileAppend [protected]
 

Append to or truncate the file? The default value for this variable is true, meaning that by default a FileAppender will append to an existing file and not truncate it.

This option is meaningful only if the FileAppender opens the file.

String fileName [protected]
 

The name of the log file.


The documentation for this class was generated from the following files:
  • fileappender.h
  • fileappender.cpp

Copyright © 1999-2004, Apache Software Foundation