## Class LoggerAppenderFile

Description

LoggerAppenderFile appends log events to a file.

This appender uses a layout.

## Configurable parameters: ##

- **file** - Path to the target file. Relative paths are resolved based on the working directory.
- **append** - If set to true, the appender will append to the file, otherwise the file contents will be overwritten.

- version: $Revision: 1382274 $
- link: Appender documentation
- license: Apache License, Version 2.0

Located in /log4php/appenders/LoggerAppenderFile.php (line 37)

    LoggerConfigurable
       |
       --LoggerAppender
          |
          --LoggerAppenderFile

Direct descendents

Class | Description
--- | ---
LoggerAppenderDailyFile | An Appender that automatically creates a new logfile each day.
LoggerAppenderRollingFile | LoggerAppenderRollingFile writes logging events to a specified file. The file is rolled over after a specified size has been reached.

Variable Summary
boolean $append
string $file
resource $fp
boolean $locking
Method Summary
void activateOptions ()
void append (LoggerLoggingEvent $event)
void close ()
boolean getAppend ()
string getFile ()
string getFileName ()
void getTargetFile ()
boolean openFile ()
void setAppend (boolean $append)
void setFile (string $file)
void setFileName (string $fileName)
void write (string $string)
void writeWithLocking ( $string)
void writeWithoutLocking ( $string)
Variables
boolean $append = true (line 54)

If set to true, appends to file. Otherwise overwrites it.

- access: protected

string $file (line 60)

Path to the target file.

- access: protected

resource $fp (line 66)

The file resource.

- access: protected

boolean $locking = true (line 48)

If set to true, the file is locked before appending. This allows concurrent access. However, appending without locking is faster so it should be used where appropriate.

TODO: make this a configurable parameter

- access: protected

#### Inherited Variables

Inherited from LoggerAppender

> LoggerAppender::$closed
> LoggerAppender::$filter
> LoggerAppender::$layout
> LoggerAppender::$name
> LoggerAppender::$requiresLayout
> LoggerAppender::$threshold

Methods
activateOptions (line 155)

- access: public

void activateOptions ()

Redefinition of:

LoggerAppender::activateOptions()
  Prepares the appender for logging.

Redefined in descendants as:

- LoggerAppenderDailyFile::activateOptions() : Additional validation for the date pattern.
- LoggerAppenderRollingFile::activateOptions()

append (line 172)

- access: public

void append (LoggerLoggingEvent $event)

- LoggerLoggingEvent $event

Redefinition of:

LoggerAppender::append()
  Forwards the logging event to the destination.

Redefined in descendants as:

- LoggerAppenderDailyFile::append() : Appends a logging event.

close (line 163)

- access: public

void close ()

Redefinition of:

LoggerAppender::close()
  Releases any resources allocated by the appender.

getAppend (line 196)

Returns the 'append' parameter.

- access: public

boolean getAppend ()
getFile (line 188)

Returns the 'file' parameter.

- access: public

string getFile ()
getFileName (line 222)

Returns the 'file' parmeter. Left for legacy reasons.

- deprecated: Use getFile() instead.
- access: public

string getFileName ()
getTargetFile (line 71)

Helper function which can be easily overriden by daily file appender.

- access: protected

void getTargetFile ()

Redefined in descendants as:

- LoggerAppenderDailyFile::getTargetFile() : Determines target file. Replaces %s in file path with a date.

openFile (line 81)

Acquires the target file resource, creates the destination folder if necessary. Writes layout header to file.

- return: FALSE if opening failed
- access: protected

boolean openFile ()
setAppend (line 204)

Sets the 'append' parameter.

- access: public

void setAppend (boolean $append)

- boolean $append

setFile (line 180)

Sets the 'file' parameter.

- access: public

void setFile (string $file)

- string $file

setFileName (line 213)

Sets the 'file' parmeter. Left for legacy reasons.

- deprecated: Use setFile() instead.
- access: public

void setFileName (string $fileName)

- string $fileName

write (line 120)

Writes a string to the target file. Opens file if not already open.

- access: protected

void write (string $string)

- string $string: Data to write.

Redefined in descendants as:

- LoggerAppenderRollingFile::write() : Writes a string to the target file. Opens file if not already open.

writeWithLocking (line 135)

- access: protected

void writeWithLocking ( $string)

- $string

writeWithoutLocking (line 148)

- access: protected

void writeWithoutLocking ( $string)

- $string

#### Inherited Methods

Inherited From LoggerAppender

> LoggerAppender::__construct()
> LoggerAppender::activateOptions()
> LoggerAppender::addFilter()
> LoggerAppender::append()
> LoggerAppender::clearFilters()
> LoggerAppender::close()
> LoggerAppender::doAppend()
> LoggerAppender::getDefaultLayout()
> LoggerAppender::getFilter()
> LoggerAppender::getFirstFilter()
> LoggerAppender::getLayout()
> LoggerAppender::getName()
> LoggerAppender::getThreshold()
> LoggerAppender::isAsSevereAsThreshold()
> LoggerAppender::requiresLayout()
> LoggerAppender::setLayout()
> LoggerAppender::setName()
> LoggerAppender::setThreshold()
> LoggerAppender::warn()
> LoggerAppender::__destruct()

Inherited From LoggerConfigurable

> LoggerConfigurable::setBoolean()
> LoggerConfigurable::setFileSize()
> LoggerConfigurable::setInteger()
> LoggerConfigurable::setLevel()
> LoggerConfigurable::setNumeric()
> LoggerConfigurable::setPositiveInteger()
> LoggerConfigurable::setString()
> LoggerConfigurable::warn()

Documentation generated on Fri, 10 Apr 2026 12:21:02 +0900 by phpDocumentor 1.4.4