LoggerAppenderSyslog
LoggerAppenderSyslog logs events to the syslog.
Layout
This appender requires a layout. If no layout is specified in configuration,
LoggerLayoutSimple will be used by default.
Parameters
The following parameters are available:
Parameter |
Type |
Required |
Default |
Description |
ident |
string |
no |
Apache log4php |
A string which will identify your appender. |
overridePriority |
boolean |
No |
false |
If set to true, all messages will be sent to the syslog using the priority specified
in the priority parameter. Otherwise, the pririty will depend on the level
of the event being logged. See below. |
priority |
string |
Yes/No |
- |
The syslog priority to use when overriding priority. This setting is required if
overridePriority is set to true. See below for
available priorities. |
facility |
string |
No |
USER |
The syslog facility. Identifies the part of the system from which the event originated.
See below for available facilities. |
option |
string |
No |
PID|CONS |
Syslog options. See below for available options. |
Priorities
The priority is the syslog equivalent of the log4php level. Here's a list of priorities
available in syslog and the equivalent log4php levels.
Priority |
Description |
Equivalent level |
EMERG |
System is unusable. |
- |
ALERT |
Action must be taken immediately. |
FATAL |
CRIT |
Critical conditions. |
- |
ERR |
Error conditions. |
ERROR |
WARNING |
Warning conditions |
WARN |
NOTICE |
Normal, but significant, condition |
- |
INFO |
Informational message |
INFO |
DEBUG |
Debug-level message |
DEBUG, TRACE |
Messages with level FATAL will be logged using the syslog's ALERT priority;
ERROR level message will use ERR priority, etc.
Note that there is no priority below DEBUG, therefore both TRACE and
DEBUG level mesages will be logged using the DEBUG syslog priority.
Facilities
The facility parameter is used to specify what type of program is logging the message. This
allows you to specify (in your machine's syslog configuration) how messages coming from different
facilities will be handled.
The following facilities are available:
Name |
Description |
KERN |
Kernel messages |
USER |
Generic user-level messages |
MAIL |
Mail system |
DAEMON |
System daemons |
AUTH |
Security/authorization messages |
SYSLOG |
Messages generated internally by syslogd |
LPR |
Line printer subsystem |
NEWS |
Network news subsystem |
UUCP |
UUCP subsystem |
CRON |
Clock daemon |
AUTHPRIV |
Security/authorization messages (private) |
LOCAL0 |
Reserved for local use |
LOCAL1 |
Reserved for local use |
LOCAL2 |
Reserved for local use |
LOCAL3 |
Reserved for local use |
LOCAL4 |
Reserved for local use |
LOCAL5 |
Reserved for local use |
LOCAL6 |
Reserved for local use |
LOCAL7 |
Reserved for local use |
Warning: USER is the only facility available on
Windows operating systems.
Options
The following additional syslog options may be defined via the option parameter:
Name |
Description |
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 messages also to standard error. |
PID |
Include the PID with each message. |
Multiple options may be set by separating them with a pipe character. For example
CONS|PID|NODELAY.
Warning: When setting multiple options in an INI configuration file,
be sure to put the options string in quotes. Otherwise they will not be parsed correctly.
Examples
Here is a sample configuration:
<configuration xmlns="http://logging.apache.org/log4php/">
<appender name="default" class="LoggerAppenderSyslog">
<layout class="LoggerLayoutSimple" />
<param name="ident" value="log4php-test" />
<param name="facility" value="LOCAL0" />
<param name="option" value="NDELAY|PID" />
</appender>
<root>
<appender_ref ref="default" />
</root>
</configuration>
array(
'appenders' => array(
'default' => array(
'class' => 'LoggerAppenderSyslog',
'layout' => array(
'class' => 'LoggerLayoutSimple',
),
'params' => array(
'ident' => 'log4php-test',
'facility' => 'LOCAL0',
'option' => 'NDELAY|PID'
),
),
),
'rootLogger' => array(
'appenders' => array('default'),
),
);
|