Class LoggerAppenderSyslog

Description

Log events to a system log using the http://www.php.net/syslog function.

This appenders requires a layout.

Configurable parameters:

  • ident - The ident of the syslog message.
  • priority - The priority for the syslog message (used when overriding priority).
  • facility - The facility for the syslog message
  • overridePriority - If set to true, the message priority will always use the value defined in $priority, otherwise the priority will be determined by the message's log level.
  • option - The option value for the syslog message.
Recognised syslog options are:
  • CONS - if there is an error while sending data to the system logger, write directly to the system console
  • NDELAY - open the connection to the logger immediately
  • ODELAY - delay opening the connection until the first message is logged (default)
  • PERROR - print log message also to standard error
  • PID - include PID with each message
Multiple options can be set by delimiting them with a pipe character, e.g.: "CONS|PID|PERROR".

Recognised syslog priorities are:

  • EMERG
  • ALERT
  • CRIT
  • ERR
  • WARNING
  • NOTICE
  • INFO
  • DEBUG
Levels are mapped as follows:
  • FATAL to LOG_ALERT
  • ERROR to LOG_ERR
  • WARN to LOG_WARNING
  • INFO to LOG_INFO
  • DEBUG to LOG_DEBUG
  • TRACE to LOG_DEBUG
An example:

  1. require_once dirname(__FILE__).'/../../main/php/Logger.php';
  2.  
  3. Logger::configure(dirname(__FILE__).'/../resources/appender_syslog.properties');
  4. $logger Logger::getRootLogger();
  5. $logger->info("Hello World!");

  1. log4php.appender.default = LoggerAppenderSyslog
  2. log4php.appender.default.layout = LoggerLayoutSimple
  3. log4php.appender.default.ident = log4php-test
  4. log4php.appender.default.facility = USER
  5. log4php.appender.default.option = "PID|CONS|NDELAY"
  6. log4php.rootLogger = DEBUG, default

  • version: $Revision: 1230527 $

Located in /appenders/LoggerAppenderSyslog.php (line 74)

LoggerConfigurable
   |
   --LoggerAppender
      |
      --LoggerAppenderSyslog
Variable Summary
string $facility
string $ident
string $option
string $priority
Method Summary
void activateOptions ()
void append (LoggerLoggingEvent $event)
void close ()
string getFacility ()
string getIdent ()
string getOption ()
string getPriority ()
void parseFacility ()
void parseOption ()
void parsePriority ()
void setFacility (string $facility)
void setIdent (string $ident)
void setOption (string $option)
void setOverridePriority (string $overridePriority)
void setPriority (string $priority)
Variables
string $facility = 'USER' (line 103)

The facility value indicates the source of the message.

  • access: protected
string $ident = "Apache log4php" (line 81)

The ident string is added to each message. Typically the name of your application.

  • access: protected
int $intFacility (line 124)

Holds the int value of the $facility.

  • access: private
int $intOption (line 130)

Holds the int value of the $option.

  • access: private
int $intPriority (line 118)

Holds the int value of the $priority.

  • access: private
string $option = 'PID|CONS' (line 96)

The option used when opening the syslog connection.

  • access: protected
string $overridePriority = false (line 112)

If set to true, the message priority will always use the value defined in $priority, otherwise the priority will be determined by the message's log level.

  • access: protected
string $priority (line 89)

The syslog priority to use when overriding priority. This setting is required if overridePriority is set to true.

  • access: protected

Inherited Variables

Inherited from LoggerAppender

LoggerAppender::$closed
LoggerAppender::$filter
LoggerAppender::$layout
LoggerAppender::$name
LoggerAppender::$requiresLayout
LoggerAppender::$threshold
Methods
activateOptions (line 223)
  • access: public
void activateOptions ()

Redefinition of:
LoggerAppender::activateOptions()
Prepares the appender for logging.
append (line 247)

Appends the event to syslog.

Log is opened and closed each time because if it is not closed, it can cause the Apache httpd server to log to whatever ident/facility was used in openlog().

  • see: 97843
  • access: public
void append (LoggerLoggingEvent $event)

Redefinition of:
LoggerAppender::append()
Forwards the logging event to the destination.
close (line 231)
  • access: public
void close ()

Redefinition of:
LoggerAppender::close()
Releases any resources allocated by the appender.
getFacility (line 200)

Returns the $facility.

  • access: public
string getFacility ()
getIdent (line 182)

Returns the $ident.

  • access: public
string getIdent ()
getOption (line 218)

Returns the $option.

  • access: public
string getOption ()
getOverridePriority (line 209)

Returns the $overridePriority.

  • access: public
string getOverridePriority ()
getPriority (line 191)

Returns the $priority.

  • access: public
string getPriority ()
getSyslogPriority (line 257)

Determines which syslog priority to use based on the given level.

  • access: private
void getSyslogPriority (LoggerLevel $level)
parseFacility (line 283)

Parses the facility string and returns the corresponding int value.

  • access: private
void parseFacility ()
parseOption (line 265)

Parses a syslog option string and returns the correspodning int value.

  • access: private
void parseOption ()
parsePriority (line 295)

Parses the priority string and returns the corresponding int value.

  • access: private
void parsePriority ()
setFacility (line 155)

Sets the $facility.

  • access: public
void setFacility (string $facility)
  • string $facility
setIdent (line 137)

Sets the $ident.

  • access: public
void setIdent (string $ident)
  • string $ident
setOption (line 173)

Sets the $option.

  • access: public
void setOption (string $option)
  • string $option
setOverridePriority (line 164)

Sets the $overridePriority.

  • access: public
void setOverridePriority (string $overridePriority)
  • string $overridePriority
setPriority (line 146)

Sets the $priority.

  • access: public
void setPriority (string $priority)
  • string $priority

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()

Inherited From LoggerConfigurable

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

Documentation generated on Sat, 18 Feb 2012 22:32:23 +0000 by phpDocumentor 1.4.3