- Main Page
- Modules
- Namespaces
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# FileAppender Class Reference

Inherits WriterAppender.

Inherited by RollingFileAppenderSkeleton.

List of all members.

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

## Public Member Functions

| FileAppender ()
| The default constructor does not do anything.
| FileAppender (const LayoutPtr &layout, const LogString &filename, bool append, bool bufferedIO, int bufferSize)
| Instantiate a `FileAppender` and open the file designated by `filename`.
| FileAppender (const LayoutPtr &layout, const LogString &filename, bool append)
| Instantiate a FileAppender and open the file designated by `filename`.
| FileAppender (const LayoutPtr &layout, const LogString &filename)
| Instantiate a FileAppender and open the file designated by `filename`.
| ~FileAppender ()
virtual void | setFile (const LogString &file)
| The File property takes a string value which should be the name of the file to append to.
virtual void | setFile (const LogString &file, bool append, bool bufferedIO, size_t bufferSize, log4cxx::helpers::Pool &p)
| Sets and opens the file where the log output will go.
bool | getAppend () const
| Returns the value of the Append option.
LogString | getFile () const
| Returns the value of the File option.
void | activateOptions (log4cxx::helpers::Pool &p)
void | setOption (const LogString &option, const LogString &value)
| Set `option` to `value`.
bool | getBufferedIO () const
| Get the value of the BufferedIO option.
int | getBufferSize () const
| Get the size of the IO buffer.
void | setAppend (bool fileAppend1)
| The Append option takes a boolean value.
void | setBufferedIO (bool bufferedIO)
| The BufferedIO option takes a boolean value.
void | setBufferSize (int bufferSize1)
| Set the size of the IO buffer.

## Static Public Member Functions

static LogString | stripDuplicateBackslashes (const LogString &name)
| Replaces double backslashes with single backslashes for compatibility with paths from earlier XML configurations files.

## Protected Attributes

bool | fileAppend
| 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.
LogString | fileName
| The name of the log file.
bool | bufferedIO
| Do we do bufferedIO?
int | bufferSize
| How big should the IO buffer be? Default is 8K.

## Constructor & Destructor Documentation

FileAppender | ( |  | ) |

| The default constructor does not do anything.

FileAppender | ( | const LayoutPtr & | layout,
|  | const LogString & | 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 LogString & | 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 LogString & | 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.

~FileAppender | ( |  | ) |

## Member Function Documentation

void activateOptions | ( | log4cxx::helpers::Pool & | p | ) | `[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 WriterAppender. Reimplemented in DailyRollingFileAppender, RollingFileAppenderSkeleton, and RollingFileAppender.

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.

LogString getFile | ( |  | ) | const`[inline]`

| Returns the value of the File option.

void setAppend | ( | bool | fileAppend1 | ) |

| 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 | bufferSize1 | ) | `[inline]`

| Set the size of the IO buffer.

virtual void setFile | ( | const LogString & | file,
|  | bool | append,
|  | bool | bufferedIO,
|  | size_t | bufferSize,
|  | log4cxx::helpers::Pool & | p
| ) | `[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. 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?
  | p | memory pool for operation.

virtual void setFile | ( | const LogString & | file | ) | `[virtual]`

| 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 LogString & | option,
|  | const LogString & | 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 WriterAppender. Reimplemented in DailyRollingFileAppender, and RollingFileAppender.

static LogString stripDuplicateBackslashes | ( | const LogString & | name | ) | `[static]`

| Replaces double backslashes with single backslashes for compatibility with paths from earlier XML configurations files.

Parameters:

  | name | file name

Returns:
  corrected file name

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

LogString fileName`[protected]`

| The name of the log file.

The documentation for this class was generated from the following file:

- fileappender.h