## Class LoggerAppender

Description

Abstract class that defines output logs strategies.

- version: $Revision: 1374777 $
- abstract:

Located in /log4php/LoggerAppender.php (line 27)

    LoggerConfigurable
       |
       --LoggerAppender

Direct descendents

Class | Description
--- | ---
LoggerAppenderNull | A NullAppender merely exists, it never outputs a message to any device.
LoggerAppenderFirePHP | Logs messages as HTTP headers using the FirePHP Insight API.
LoggerAppenderEcho | LoggerAppenderEcho uses the PHP echo() function to output events.
LoggerAppenderFile | LoggerAppenderFile appends log events to a file.
LoggerAppenderSyslog | Log events to a system log using the PHP syslog() function.
LoggerAppenderConsole | LoggerAppenderConsole appends log events either to the standard output stream (php://stdout) or the standard error stream (php://stderr).
LoggerAppenderMail | LoggerAppenderMail appends log events via email.
LoggerAppenderPDO | LoggerAppenderPDO appender logs to a database using the PHP's PDO extension.
LoggerAppenderMailEvent | LoggerAppenderMailEvent appends individual log events via email.
LoggerAppenderMongoDB | Appender for writing to MongoDB.
LoggerAppenderPhp | LoggerAppenderPhp logs events by creating a PHP user-level message using the PHP's trigger_error()function.
LoggerAppenderSocket | LoggerAppenderSocket appends to a network socket.

Variable Summary
boolean $closed
LoggerFilter $filter
LoggerLayout $layout
string $name
boolean $requiresLayout
LoggerLevel $threshold
Method Summary
LoggerAppender __construct ([string $name = ''])
void __destruct ()
void activateOptions ()
void addFilter (LoggerFilter $filter)
void append (LoggerLoggingEvent $event)
void clearFilters ()
void close ()
void doAppend (LoggerLoggingEvent $event)
LoggerLayout getDefaultLayout ()
LoggerFilter getFilter ()
LoggerFilter getFirstFilter ()
LoggerLayout getLayout ()
string getName ()
LoggerLevel getThreshold ()
boolean isAsSevereAsThreshold (LoggerLevel $level)
boolean requiresLayout ()
void setLayout (LoggerLayout $layout)
void setName (string $name)
void setThreshold (LoggerLevel|string $threshold)
void warn ( $message)
Variables
boolean $closed = false (line 34)

Set to true when the appender is closed. A closed appender will not accept any logging requests.

- access: protected

LoggerFilter $filter (line 40)

The first filter in the filter chain.

- access: protected

LoggerLayout $layout (line 47)

The appender's layout. Can be null if the appender does not use a layout.

- access: protected

string $name (line 53)

Appender name. Used by other components to identify this appender.

- access: protected

boolean $requiresLayout = true (line 70)

Set to true if the appender requires a layout.

True by default, appenders which do not use a layout should override this property to false.

- access: protected

Redefined in descendants as:

- LoggerAppenderNull::$requiresLayout : This appender does not require a layout.
- LoggerAppenderPDO::$requiresLayout : This appender does not require a layout.

LoggerLevel $threshold (line 60)

Appender threshold level. Events whose level is below the threshold will not be logged.

- access: protected

Methods
Constructor __construct (line 76)

Default constructor.

- access: public

LoggerAppender __construct ([string $name = ''])

- string $name: Appender name

Redefined in descendants as:

- LoggerAppenderRollingFile::__construct()
- LoggerAppenderMongoDB::__construct()

Destructor __destruct (line 84)

- access: public

void __destruct ()
activateOptions (line 257)

Prepares the appender for logging.

Derived appenders should override this method if option structure requires it.

- access: public

void activateOptions ()

Redefined in descendants as:

- LoggerAppenderFirePHP::activateOptions()
- LoggerAppenderFile::activateOptions()
- LoggerAppenderDailyFile::activateOptions() : Additional validation for the date pattern.
- LoggerAppenderRollingFile::activateOptions()
- LoggerAppenderSyslog::activateOptions()
- LoggerAppenderConsole::activateOptions()
- LoggerAppenderPDO::activateOptions() : Acquires a database connection based on parameters.
- LoggerAppenderMailEvent::activateOptions()
- LoggerAppenderMongoDB::activateOptions() : Setup db connection.
- LoggerAppenderSocket::activateOptions()

addFilter (line 102)

Adds a filter to the end of the filter chain.

- access: public

void addFilter (LoggerFilter $filter)

- LoggerFilter $filter: add a new LoggerFilter

append (line 268)

Forwards the logging event to the destination.

Derived appenders should implement this method to perform actual logging.

- abstract:
- access: protected

void append (LoggerLoggingEvent $event)

- LoggerLoggingEvent $event

Redefined in descendants as:

- LoggerAppenderNull::append() : Do nothing.
- LoggerAppenderFirePHP::append()
- LoggerAppenderEcho::append()
- LoggerAppenderFile::append()
- LoggerAppenderDailyFile::append() : Appends a logging event.
- LoggerAppenderSyslog::append() : Appends the event to syslog.
- LoggerAppenderConsole::append()
- LoggerAppenderMail::append()
- LoggerAppenderPDO::append() : Appends a new event to the database.
- LoggerAppenderMailEvent::append()
- LoggerAppenderMongoDB::append() : Appends a new event to the mongo database.
- LoggerAppenderPhp::append()
- LoggerAppenderSocket::append()

clearFilters (line 113)

Clears the filter chain by removing all the filters in it.

- access: public

void clearFilters ()
close (line 276)

Releases any resources allocated by the appender.

Derived appenders should override this method to perform proper closing procedures.

- access: public

void close ()

Redefined in descendants as:

- LoggerAppenderEcho::close()
- LoggerAppenderFile::close()
- LoggerAppenderSyslog::close()
- LoggerAppenderConsole::close()
- LoggerAppenderMail::close()
- LoggerAppenderPDO::close() : Closes the connection to the logging database
- LoggerAppenderMongoDB::close() : Closes the connection to the logging database

doAppend (line 141)

Performs threshold checks and invokes filters before delegating logging to the subclass' specific append() method.

- see: LoggerAppender::append()
- access: public

void doAppend (LoggerLoggingEvent $event)

- LoggerLoggingEvent $event

getDefaultLayout (line 94)

Returns the default layout for this appender. Can be overriden by derived appenders.

- access: public

LoggerLayout getDefaultLayout ()

Redefined in descendants as:

- LoggerAppenderSocket::getDefaultLayout() : Override the default layout to use serialized.

getFilter (line 122)

Returns the first filter in the filter chain.

The return value may be null if no is filter is set.

- access: public

LoggerFilter getFilter ()
getFirstFilter (line 131)

Returns the first filter in the filter chain.

The return value may be null if no is filter is set.

- access: public

LoggerFilter getFirstFilter ()
getLayout (line 175)

Returns the appender layout.

- access: public

LoggerLayout getLayout ()
getName (line 204)

Retruns the appender name.

- access: public

string getName ()
getThreshold (line 220)

Returns the appender's threshold level.

- access: public

LoggerLevel getThreshold ()
isAsSevereAsThreshold (line 244)

Checks whether the message level is below the appender's threshold.

If there is no threshold set, then the return value is always true.

- return: Returns true if level is greater or equal than threshold, or if the threshold is not set. Otherwise returns false.
- access: public

boolean isAsSevereAsThreshold (LoggerLevel $level)

- LoggerLevel $level

requiresLayout (line 196)

Configurators call this method to determine if the appender requires a layout.

If this method returns true, meaning that layout is required, then the configurator will configure a layout using the configuration information at its disposal. If this method returns false, meaning that a layout is not required, then layout configuration will be skipped even if there is available layout configuration information at the disposal of the configurator.

In the rather exceptional case, where the appender implementation admits a layout but can also work without it, then the appender should return true.

- access: public

boolean requiresLayout ()
setLayout (line 165)

Sets the appender layout.

- access: public

void setLayout (LoggerLayout $layout)

- LoggerLayout $layout

setName (line 212)

Sets the appender name.

- access: public

void setName (string $name)

- string $name

setThreshold (line 231)

Sets the appender threshold.

- see: LoggerOptionConverter::toLevel()
- access: public

void setThreshold (LoggerLevel|string $threshold)

- LoggerLevel|string $threshold: Either a LoggerLevel object or a string equivalent.

warn (line 281)

Triggers a warning for this logger with the given message.

- access: protected

void warn ( $message)

- $message

Redefinition of:

LoggerConfigurable::warn()
  Triggers a warning.

#### Inherited Methods

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:01 +0900 by phpDocumentor 1.4.4