Modified: logging/site/trunk/docs/log4php/docs/appender/appender.html URL: http://svn.apache.org/viewvc/logging/site/trunk/docs/log4php/docs/appender/appender.html?rev=1180134&r1=1180133&r2=1180134&view=diff ============================================================================== --- logging/site/trunk/docs/log4php/docs/appender/appender.html (original) +++ logging/site/trunk/docs/log4php/docs/appender/appender.html Fri Oct 7 18:26:07 2011 @@ -1,19 +1,34 @@ - + - Apache log4php - Appenders + Appenders - + - + + +

Appender Reference

The following appenders are included with log4php.

NameDestination
LoggerAppenderEchoConsole, using the PHP echo command.
LoggerAppenderConsoleSTDOUT or STDERR
LoggerAppenderFileA file.
LoggerAppenderDailyFile A file (new file each day).
LoggerAppenderRollingFileA file (new file when a specified size has been reached).
LoggerAppenderMailSends the log via email. The entire log is sent in one email.
LoggerAppenderMailEventSends the log via email. Each log entry is sent in individual emails.
LoggerAppenderMongoDBMongoDB.
LoggerAppenderNullIgnores all log events.
LoggerAppenderPDODatabase.
LoggerAppenderPhpCreates a PHP user-level message using the PHP trigger_error function.
LoggerAppenderSocketA network socket.
LoggerAppenderSyslogSyslog.

LoggerAppenderEcho

The LoggerAppenderEcho appender writes logging events using PHP's echo function. Echo outputs may be buffered.

Configurable parameters
ParameterRequiredDefault valueDescription
htmlLineBreaksNofalseIf set to true, a <br /> element will be inserted before each line break in the logged message.
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderEcho">
+

The logger will forward this logging requests to all appenders which are linked with it. In our example, the output will be written both to console and to the file.

Appender Reference

The following appenders are included with log4php.

NameDestination
LoggerAppenderEchoConsole, using the PHP echo command.
LoggerAppenderConsoleSTDOUT or STDERR
LoggerAppenderFileA file.
LoggerAppenderDailyFileA file (new file each day).
LoggerAppenderRollingFileA file (new file when a specified size has been reached).
LoggerAppenderMailSends the log via email. The entire log is sent in one email.
LoggerAppenderMailEventSends the log via email. Each log entry is sent in individual emails.
LoggerAppenderMongoDBMongoDB.
LoggerAppenderNullIgnores all log events.
LoggerAppenderPDODatabase.
LoggerAppenderPhpCreates a PHP user-level message using the PHP trigger_error function.
LoggerAppenderSocketA network socket.
LoggerAppenderSyslogSyslog.

LoggerAppenderEcho

The LoggerAppenderEcho appender writes logging events using PHP's echo function. Echo outputs may be buffered.

Configurable parameters
ParameterRequiredDefault valueDescription
htmlLineBreaksNofalseIf set to true, a <br /> element will be inserted before each line break in the logged message.
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderEcho">
     <layout class="LoggerLayoutTTCC" />
     <param name="htmlLineBreaks" value="true" />
 </appender>
 

Configuration via ini file:

log4php.appender.default = LoggerAppenderEcho
 log4php.appender.default.layout = LoggerLayoutTTCC
 log4php.appender.default.htmlLineBreaks = "true"
-

LoggerAppenderConsole

The LoggerAppenderConsoler appender writes logging events to the STDOUT (php://stdout) or STDERR (php://stderr) stream. Defaults to STDOUT.

Configurable parameters
ParameterRequiredDefault valueDescription
targetNostdoutSets the otuput stream to which this appender should write to. Possible values are "stdout" for standard output stream and "stderr" for standard error stream.
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderConsole">
+

LoggerAppenderConsole

The LoggerAppenderConsoler appender writes logging events to the STDOUT (php://stdout) or STDERR (php://stderr) stream. Defaults to STDOUT.

Configurable parameters
ParameterRequiredDefault valueDescription
targetNostdoutSets the otuput stream to which this appender should write to. Possible values are "stdout" for standard output stream and "stderr" for standard error stream.
Examples

Configuration via XML file:

<appender name=&q
 uot;default" class="LoggerAppenderConsole">
     <layout class="LoggerLayoutTTCC" />
     <param name="target" value="STDOUT" />
 </appender>
 

Configuration via ini file:

log4php.appender.console = LoggerAppenderConsole
 log4php.appender.console.target = STDOUT
 log4php.appender.console.layout = LoggerLayoutTTCC
-

LoggerAppenderFile

The LoggerAppenderFile writes logging events to a file.

Configurable parameters
ParameterRequiredDefault valueDescription
fileYes-Path to the target file.
appendNotrueDefines if the appender should append to the end of the file ("true") or truncate the file before writing ("false").
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderFile">
+

LoggerAppenderFile

The LoggerAppenderFile writes logging events to a file.

Configurable parameters
ParameterRequiredDefault valueDescription
fileYes-Path to the target file.
appendNotrueDefines if the appender should append to the end of the file ("true") or truncate the file before writing ("false").
Examples

Configuration via XML file:

<ap
 pender name="default" class="LoggerAppenderFile">
     <layout class="LoggerLayoutTTCC" />
     <param name="file" value="target/examples/file.log" />
 </appender>
 

Configuration via ini file:

log4php.appender.default = LoggerAppenderFile
 log4php.appender.default.file = target/examples/file.log
 log4php.appender.default.layout = LoggerLayoutTTCC
-

LoggerAppenderDailyFile

The LoggerAppenderDailyFile writes logging events to a specified file. The file is rolled over once a day. That means, for each day a new file is created.

The path specified in the file parameter should contain the string '%s' which will be substituted with the current date when logging. The datePattern parameter determines how the date will be formatted. It follows the formatting rules used by PHP's date function.

Configurable parameters
ParameterRequiredDefault valueDescription
file< /td>Yes-Path to the target file. Should contain a '%s' which gets substituted by the date.
appendNotrueDefines if the appender should append to the end of the file ("true") or truncate the file before writing ("false").
datePatternNoYmdDate format for the date in the file path.
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderDailyFile">
+

LoggerAppenderDailyFile

The LoggerAppenderDailyFile writes logging events to a specified file. The file is rolled over once a day. That means, for each day a new file is created.

The path specified in the file parameter should contain the string '%s' which will be substituted with the current date when logging. The datePattern parameter determines how the date will be formatted. It follows the formatting rules used by PHP's date function.

Configurable parameters
ParameterRequiredDefault valueDescription
fileYes -Path to the target file. Should contain a '%s' which gets substituted by the date.
appendNotrueDefines if the appender should append to the end of the file ("true") or truncate the file before writing ("false").
datePatternNoYmdDate format for the date in the file path.
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderDailyFile">
     <layout class="LoggerLayoutTTCC" />
     <param name="datePattern" value="Y-m-d" />
     <param name="file" value="/var/log/daily_%s.log" />
@@ -227,7 +242,7 @@ log4php.appender.default.layout = Logger
 log4php.appender.default.layout = LoggerLayoutTTCC
 log4php.appender.default.datePattern = Y-m-d
 log4php.appender.default.file = /var/log/daily_%s.log
-

Let's say, for example, that today is May 5th 2010. Using the above configuration, LoggerAppenderDailyFile will log to /var/log/daily_2010-05-05.log

LoggerAppenderRollingFile

The LoggerAppenderDailyFile appender writes logging events to a file. The file is rolled over after a specified size has been reached.

ParameterRequiredDefault valueDescription
fileYes-Path to the target file.
appendNotrueDefines if the appender should append to the end of the file ("true") o r truncate the file before writing ("false").
datePatternNoYmdDate format for the date in the file path.
maxBackupIndexNo1Maximum number of backup files to keep.
maxFileSizeNo10MBMaximum allowed file size (in bytes) before rolling over. Suffixes "KB", "MB" and "GB" are allowed. 10KB = 10240 bytes, etc.
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderRollingFile">
+

Let's say, for example, that today is May 5th 2010. Using the above configuration, LoggerAppenderDailyFile will log to /var/log/daily_2010-05-05.log

LoggerAppenderRollingFile

The LoggerAppenderDailyFile appender writes logging events to a file. The file is rolled over after a specified size has been reached.

ParameterRequiredDefault valueDescription
fileYes-Path to the target file.
appendNotrueDefines if the appender should append to the end of the file ("true") or truncate the file before writing (&quo t;false").
datePatternNoYmdDate format for the date in the file path.
maxBackupIndexNo1Maximum number of backup files to keep.
maxFileSizeNo10MBMaximum allowed file size (in bytes) before rolling over. Suffixes "KB", "MB" and "GB" are allowed. 10KB = 10240 bytes, etc.
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderRollingFile">
     <layout class="LoggerLayoutTTCC" />
     <param name="file" value="target/examples/appender_rollingfile.log" />
     <param name="maxFileSize" value="10MB" />
@@ -238,7 +253,7 @@ log4php.appender.default.layout = Logger
 log4php.appender.default.file = target/examples/appender_rollingfile.log
 log4php.appender.default.maxFileSize = 10MB
 log4php.appender.default.maxBackupIndex = 3
-

The resulting filenames are appender_rollingfile.log, appender_rollingfile.log.1, appender_rollingfile.log.2 and so on.

LoggerAppenderMail

The LoggerAppenderMail appends log events via email.

This appender will not send individual emails for each logging requests, but will collect them in a buffer and send them all in a single email once the appender is closed.

Configurable parameters
ParameterRequiredDefault valueDescription
toYes-Email address to which the log will be sent
fromYes-Email address of the sender
subjectYes-Subject of the mail
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderMail">
+

The resulting filenames are appender_rollingfile.log, appender_rollingfile.log.1, appender_rollingfile.log.2 and so on.

LoggerAppenderMail

The LoggerAppenderMail appends log events via email.

This appender will not send individual emails for each logging requests, but will collect them in a buffer and send them all in a single email once the appender is closed.

Configurable parameters
ParameterRequiredDefault valueDescription
toYes-Email address to which the log will be sent
fromYes-Email address of the sender
subjectYes-Subject of the mail
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderMail">
     <layout class="LoggerLayoutTTCC" />
     <param name="from" value="someone@example.com" />
     <param name="to" value="root@localhost" />
@@ -249,7 +264,7 @@ log4php.appender.default.layout = Logger
 log4php.appender.default.from = someone@example.com
 log4php.appender.default.to = root@localhost
 log4php.appender.default.subject = log4php test
-

LoggerAppenderMailEvent

The LoggerAppenderMailEvent appends log events to mail.

This appender is similar to the LoggerAppenderMail appender, except that it sends each each log event in an individual email message at the time when it occurs.

Configurable parameters
ParameterRequiredDefault valueDescription
toYes-Email address to which the log will be sent
fromYes-Email address of the sender
subjectYes-Subject of the mail
smtpHostNoini_get('SMTP')Used to override the SMTP server used for sending the email. Only works on Windows
portNo25Used to override the default SMTP server port. Only works on Windows
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderMailEvent">
+

LoggerAppenderMailEvent

The LoggerAppenderMailEvent appends log events to mail.

This appender is similar to the LoggerAppenderMail appender, except that it sends each each log event in an individual email message at the time when it occurs.

Configurable parameters
ParameterRequiredDefault valueDescription
toYes-Email address to which the log will be sent
fromYes-Email address of the sender
subjectYes-Subject of the mail
smtpHostNoini_get('SMTP')Used to override the SMTP server used for sending the email. Only works on Windows
portNo25Used to override the default SMTP server port. Only works on Windows
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderMailEvent">
     <layout class="LoggerLayoutTTCC" />
     <param name="from" value="someone@example.com" />
     <param name="to" value="root@localhost" />
@@ -260,7 +275,7 @@ log4php.appender.default.layout = Logger
 log4php.appender.default.from = someone@example.com
 log4php.appender.default.to = root@localhost
 log4php.appender.default.subject = log4php test
-

LoggerAppenderMongoDB

The LoggerAppenderMongoDB appends log events to a mongoDB instance.

MongoDB is a scalable, high-performance, open source, document-oriented database.

Configurable parameters
ParameterRequiredDefault valueDescription
hostNomongodb://localhostServer on which mongodb instance is located.
portNo27017Port on which the instance is bound.
databaseNameNolog4php_mongodbName of the database to which to log.
collectionNameNologsName of the collection within the given database.
usernameNo-Username used to connect to the database.
passwordNo-Password used to connect to the database.
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderMongoDB">
+

LoggerAppenderMongoDB

The LoggerAppenderMongoDB appends log events to a mongoDB instance.

MongoDB is a scalable, high-performance, open source, document-oriented database.

Configurable parameters
ParameterRequiredDefault valueDescription
hostNomongodb://localhostServer on which mongodb instance is located.
portNo27017Port on which the instance is bound.
databaseNameNolog4php_mongodbName of the database to which to log.
collectionNameNologsName of the collection within the given database.
usernameNo-Username used to connect to the database.
passwordNo-Password used to connect to the database.
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderMongoDB">
     <param name="host" value="mongodb://myhost.com" />
     <param name="username" value="logger" />
     <param name="password" value="secret" />
@@ -269,9 +284,9 @@ log4php.appender.default.subject = log4p
 log4php.appender.default.host = mongodb://myhost.com
 log4php.appender.default.username = logger
 log4php.appender.default.password = secret
-

LoggerAppenderNull

The LoggerAppenderNull appender ignores all log events.

This appender does not use a layout and has no configurable parameters.

Configuration via XML file:

<appender name="default" class="LoggerAppenderNull" />
+

LoggerAppenderNull

The LoggerAppenderNull appender ignores all log events.

This appender does not use a layout and has no configurable parameters.

Configuration via XML file:

<appender name="default" class="LoggerAppenderNull" />
 

Configuration via ini file:

log4php.appender.default = LoggerAppenderNull
-

LoggerAppenderPDO

The LoggerAppenderPDO appender logs to a database using the PHP's PDO extension.

ParameterRequiredDefault valueDescription
dsnYes-The Data Source Name (DSN) used to connect to the database.
userYes-Username used to connect to the database.
passwordYes-Password used to connect to the database.
createTableNotrueCreate the table if it does not exist? ("true" or "false")
tableNolog4php_logName of the table to which log entries should be inserted.
insertSqlNosee belowSQL query used to insert a log event.
insertPatternNosee belowA comma separated list of LoggerPatternLayout format strings used in insertSql parameter.

Parameters dsn, user and password are used by PDO to connect to the database which will be used for logging. For available database drivers and corres ponding DSN format, please see the PDO driver documentation.

Advanced configuration

Parameters insertSql and insertPattern can be used to change how events are inserted into the database. By manipulating them, it is possible to use a custom table structure to suit your needs.

  WARNING: Change these settings only if you are sure what you are doing.
+

LoggerAppenderPDO

The LoggerAppenderPDO appender logs to a database using the PHP's PDO extension.

ParameterRequiredDefault valueDescription
dsnYes-The Data Source Name (DSN) used to connect to the database.
userYes-Username used to connect to the database.
passwordYes-Password used to connect to the database.
createTableNotrueCreate the table if it does not exist? ("true" or "false")
tableNolog4php_logName of the table to which log entries should be inserted.
insertSqlNosee belowSQL query used to insert a log event.
insertPatternNosee belowA comma separated list of LoggerPatternLayout format strings used in insertSql parameter.

Parameters dsn, user and password are used by PDO to connect to the database which will be used for logging. For available database drivers and corresponding DSN format, please see t he PDO driver documentation.

Advanced configuration

Parameters insertSql and insertPattern can be used to change how events are inserted into the database. By manipulating them, it is possible to use a custom table structure to suit your needs.

  WARNING: Change these settings only if you are sure what you are doing.
 

By default their values are:

insertSqlINSERT INTO __TABLE__ (timestamp, logger, level, message, thread, file, line) VALUES (?, ?, ?, ?, ?, ?, ?)
insertPattern%d,%c,%p,%m,%t,%F,%L

The string __TABLE__ in insertSql will be replaced with the table name defined in the table parameter. Question marks in the insertSql will be replaced by evaluated LoggerPatternLayout format strings defined in insertPattern. See LoggerPatternLayout documentation for format string description.

Example 1

The simplest example is connecting to an SQLite database which does not require any authentication.

Configuration via XML file:

<appender name="default" class=&qu
 ot;LoggerAppenderPDO">
     <param name="dsn" value="sqlite:target/appender_pdo.sqlite" />
 </appender>
@@ -307,12 +322,12 @@ log4php.appender.default.table = my_log
  +-------------------------+--------+-------+--------------+--------+------------------------------------------------------------------+------+
  | 2009-09-08 02:31:48,532 | root   | FATAL | Hello World! | 21858  | /srv/home/james/workspace/log4php/src/examples/php/appender_pdo. | 24   |
  +-------------------------+--------+-------+--------------+--------+------------------------------------------------------------------+------+
-

LoggerAppenderPhp

The LoggerAppenderPhp appender logs events by creating a PHP user-level message using the php function trigger_error.

The message type depends on the event's severity level:

  • E_USER_NOTICE is used when the event's level is equal to or less than INFO
  • E_USER_WARNING is used when the event's level is equal to WARN
  • E_USER_ERROR is used when the event's level is equal to or greater than ERROR

This appender has no configurable parameters.

Example

Configuration via xml file:

<appender name="default" class="LoggerAppenderPhp">
+

LoggerAppenderPhp

The LoggerAppenderPhp appender logs events by creating a PHP user-level message using the php function trigger_error.

The message type depends on the event's severity level:

  • E_USER_NOTICE is used when the event's level is equal to or less than INFO
  • E_USER_WARNING is used when the event's level is equal to WARN
  • E_USER_ERROR is used when the event's level is equal to or greater than ERROR

This appender has no configurable parameters.

Example

Configuration via xml file:

<appender name="default" class="LoggerAppenderPhp">
     <layout class="LoggerLayoutTTCC" />
 </appender>
 

Configuration via ini file:

log4php.appender.default = LoggerAppenderPhp
 log4php.appender.default.layout = LoggerLayoutTTCC
-

LoggerAppenderSocket

The LoggerAppenderSocket appender serializes log events and sends them to a network socket.

ParameterRequiredDefault valueDescription
remoteHostYes-Target host. On how to define a remote hostname see fsockopen() documentation.
portNo4446Target port of the socket.
timeoutNo30Timeout in ms
useXmlNofalseIf set to "true" the appender will sent the event formatted in XML, if set to "false" the appender will send the event as a serialized PHP object.
locationInfoNofalseWhether location info is included for the XML event format. Ignored if XML format is not used.
log4jNamespaceNofalseIn XML format, log4php namespace is used by default. If this parameter is set to true, log4j namespace will be used instead.
Example 1

In this example, log events are sent to localhost:4242, using serialized objects format. The host will recieve a serialized Logge rLoggingEvent object.

Configuration via xml file:

<appender name="default" class="LoggerAppenderSocket">
+

LoggerAppenderSocket

The LoggerAppenderSocket appender serializes log events and sends them to a network socket.

ParameterRequiredDefault valueDescription
remoteHostYes-Target host. On how to define a remote hostname see fsockopen() documentation.
portNo4446Target port of the socket.
timeoutNo30Timeout in ms
useXmlNofalseIf set to "true" the appender will sent the event formatted in XML, if set to "false" the appender will send the event as a serialized PHP object.
locationInfoNofalseWhether location info is included for the XML event format. Ignored if XML format is not used.
log4jNamespaceNofalseIn XML format, log4php namespace is used by default. If this parameter is set to true, log4j namespace will be used instead.
Example 1

In this example, log events are sent to localhost:4242, using serialized objects format. The host will recieve a serialized LoggerLoggingEvent object.

Config uration via xml file:

<appender name="default" class="LoggerAppenderSocket">
     <layout class="LoggerLayoutSimple" />
     <param name="remoteHost" value="localhost" />
     <param name="port" value="4242" />
@@ -340,8 +355,9 @@ log4php.appender.default.locationInfo = 
     <log4php:message><![CDATA[Hello World!]]></log4php:message>
     <log4php:locationInfo class="main" file="D:\Projects\php-devel\org.apache.log4php\src\examples\php\appender_socket.php" line="23" method="main" />
 </log4php:event>
-

If locationInfo was set to false, the log4php:locationInfo would not be present.

If log4jNamespace was set to true, all elements would be prefixed by log4j: instead log4php:.

LoggerAppenderSyslog

The LoggerAppenderSyslog logs events to the syslog.

ParameterRequiredDefault valueDescription
identNoLog4PHP Syslog-EventA string which will identify your appender.
overridePriorityNofalseIf set to true, all messages will be sent to the syslog using the priority sp ecified in the priority parameter. Otherwise, the pririty will depend on the level of the event being logged. See below.
priorityNo/Yes-The syslog priority to use when overriding priority. This setting is required if overridePriority is set to true.
facilityNoUSERThe syslog facility. Identifies the part of the system from which the event originated. See below.
optionNoPID  u007C CONSSyslog options. See below.
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 .

PriorityDescriptionEquivalent level
EMERGSystem is unusable-
ALERTAction must be taken immediatelyFATAL
CRITCritical conditions-
ERRError conditionsERROR
WARNINGWarning conditionsWARN
NOTICENormal, but significant, condition-
INFOInformational messageINFO
DEBUGDebug-level messageDEBUG, TRACE

This means that messages with level FATAL will be logged using the syslog's ALERT priority; ERROR 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:

NameDescription
KERNKernel messages
USERGeneric user-level messages
MAILMail system
DAEMONSystem daemons
AUTHSecurity/authorization messages
SYSLOGMessages generated internally by syslogd
LPRLine printer subsystem
NEWSNetwork news subsystem
UUCPUUCP subsystem
CRONClock daemon
AUTHPRIVSecurity/authorization messages (private)
LOCAL0Reserved for local use
LOCAL1< /td>Reserved for local use
LOCAL2Reserved for local use
LOCAL3Reserved for local use
LOCAL4Reserved for local use
LOCAL5Reserved for local use
LOCAL6Reserved for local use
LOCAL7Reserved for local use
  Note: USER is the only available facility under Windows operating systems.
-
Options

The following additional options may be defined via the option parameter:

NameDescription
CONSIf there is an error while sending data to the system logger, write directly to the system console
NDELAYOpen the connection to the logger immediately.
ODELAYDelay opening the connection until the first message is logged (default).
PERRORPrint log messages also to standard error.
PIDInclude the PID with each message.

Multiple options may be set by separating them with a "|" . For exampe "CONS|PID|NODELAY".

Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderSyslog">
+

If locationInfo was set to false, the log4php:locationInfo would not be present.

If log4jNamespace was set to true, all elements would be prefixed by log4j: instead log4php:.

LoggerAppenderSyslog

The LoggerAppenderSyslog logs events to the syslog.

ParameterRequiredDefault valueDescription
identNoApache log4phpA string which will identify your appender.
overridePriorityNofalseIf 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.
priorityNo/Yes-The syslog priority to use when overriding priority. This setting is required if overridePriority is set to true.
facilityNoUSERThe syslog facility. Identifies the part of the system from which the event originated. See below.
optionNoPID  u007C CONSSyslog options. See below.
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.

PriorityDescriptionEquivalent level
EMERGSystem is unusable-
ALERTAction must be taken immediatelyFATAL
CRITCritical conditions-
ERRError conditionsERROR
WARNINGWarning conditionsWARN
NOTICENormal, but significant, condition-
INFOInformational messageINFO
DEBUGDeb ug-level messageDEBUG, TRACE

This means that messages with level FATAL will be logged using the syslog's ALERT priority; ERROR 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:

NameDescription
KERNKernel messages
USERGeneric user-level messages
MAILMail system
DAEMONSystem daemons
AUTHSecurity/authorization messages
SYSLOGMessages generated internally by syslogd
LPRLine printer subsystem
NEWSNetwork news subsystem
UUCPUUCP subsystem
CRONClock daemon
AUTHPRIVSecurity/authorization messages (private)
LOCAL0Reserved for local use
LOCAL1Reserved for local u se
LOCAL2Reserved for local use
LOCAL3Reserved for local use
LOCAL4Reserved for local use
LOCAL5Reserved for local use
LOCAL6Reserved for local use
LOCAL7Reserved for local use
  Note: USER is the only available facility under Windows operating systems.
+
Options

The following additional options may be defined via the option parameter:

NameDescription
CONSIf there is an error while sending data to the system logger, write directly to the system console
NDELAYOpen the connection to the logger immediately.
ODELAYDelay opening the connection until the first message is logged (default).
PERRORPrint log messages also to standard error.
PIDInclude the PID with each message.

Multiple options may be set by separating them with a pipe characte r. For exampe "CONS|PID|NODELAY".

NOTE: when setting multiple options in an INI file, be sure to put the options string in quotes. Otherwise they will not be parsed correctly.
+
Examples

Configuration via XML file:

<appender name="default" class="LoggerAppenderSyslog">
     <layout class="LoggerLayoutSimple" />
     <param name="ident" value="log4php-test" />
     <param name="facility" value="LOCAL0" />
@@ -351,7 +367,7 @@ log4php.appender.default.locationInfo = 
 log4php.appender.default.layout = LoggerLayoutSimple
 log4php.appender.default.ident = log4php-test
 log4php.appender.default.facility = LOCAL0
-log4php.appender.default.options = NDELAY|PID
+log4php.appender.default.options = "NDELAY|PID"
 
@@ -364,7 +380,7 @@ log4php.appender.default.options = NDELA Apache Software Foundation. - Licensed under the Apache Software License, Version 2.0.
+ Licensed under the Apache Software License, Version 2.0. Please read the privacy policy
Apache log4php, Apache, log4php, the Apache feather logo, the Apache Logging Services project logo and the Built by Maven logo are trademarks of The Apache Software Foundation.
Modified: logging/site/trunk/docs/log4php/docs/appender/filter.html URL: http://svn.apache.org/viewvc/logging/site/trunk/docs/log4php/docs/appender/filter.html?rev=1180134&r1=1180133&r2=1180134&view=diff ============================================================================== --- logging/site/trunk/docs/log4php/docs/appender/filter.html (original) +++ logging/site/trunk/docs/log4php/docs/appender/filter.html Fri Oct 7 18:26:07 2011 @@ -1,19 +1,34 @@ - + - Apache log4php - Appender Filters + Appender Filters - + - + + +

Filter reference

The following filters are available in log4php:

NameDescription
LoggerFilterDenyAllDenies all logging events.
LoggerFilterLevelMatchFilters based on logging event level.
LoggerFilterLevelRangeFilters based on logging event level range.
LoggerFilterStringMatchFilters by searching for a string in the logging event message.

LoggerFilterDenyAll

This filters simply denies all logging events. It has no configurable paramet ers.

LoggerFilterLevelMatch

This filter accepts the specified logger level or denys it.

Configurable parameters
ParameterRequiredDefault valueDescription
levelToMatchYes-The level to match
acceptOnMatchNotrueIf true, the matching log level is accepted, denied otherwise
Example
<filter class="LoggerFilterLevelMatch">
+

In this example, there are two filters defined for the default appender.

The first filter (LoggerFilterStringMatch) searches for the string "interesting" in the logging event's message. If the string is found, the filter will ACCEPT the logging event, and the event will be logged. If the string is not found, the filter will remain NEUTRAL, and the event will be passed on to the next filter.

The second filter (LoggerFilterLevelRange) ACCEPTS all events which have a level between DEBUG and ERROR (in other words, levels DEBUG, INFO, WARN and ERROR). It DENIES all other events.

Therefore, this filter configuration will log events which which have a level between DEBUG and ERROR, except of theose which have the string "interesting" in the message. Those will be logged regardless of their level.

Filter reference

The following filters are available in log4php:

NameDescription
LoggerFilterDenyAllDenies all logging events.
LoggerFilterLevelMatchFilters based on logging event level.
LoggerFilterLevelRangeFilters based on logging event level range.
LoggerFilterStringMatchFilters by searching for a string in the logging event message.

LoggerFilterDenyAll

This filters simply denies all logging events. It has no configurable parameters.

LoggerFilterLevelMatch

This filter accepts the specified logger level or denys it.

Configurable parameters
ParameterRequiredDefault valueDescription
levelToMatchYes-The level to match
acceptOnMatchNotrueIf true, the matching log level is accepted, denied otherwise
Example
<filter class="LoggerFilterLevelMatch">
     <param name="levelToMatch" value="debug" />
     <param name="acceptOnMatch" value="false" />
 </filter>
-

LoggerFilterLevelRange

This filter accepts or denies logging events if their log level is within the specified range.

Configurable parameters
< td align="left">true
ParameterRequiredDefault valueDescription
levelMinNo-The minimum level to log. If set, levels lower than this will be denied.
levelMaxNo-The maximum level to log. If set, levels higher than this will be denied.
acceptOnMatchNoIf true, the matching log level is accepted, denied otherwise.
Example
<filter class="LoggerFilterLevelRange">
+

LoggerFilterLevelRange

This filter accepts or denies logging events if their log level is within the specified range.

Configurable parameters
ParameterRequiredDefault valueDescription
levelMinNo-The minimum level to log. If set, levels lower than this will be denied.
levelMaxNo-The maximum level to log. If set, levels higher than this will be denied.
acceptOnMatchNotrueIf true, the matching log level is accepted, denied otherwise.
Example
<filter class="LoggerFilterLevelRange">
     <param name="levelMax" value="warn" />
     <param name="acceptOnMatch" value="false" />
 </filter>
-

This configuration denies levels greater than WARN.

LoggerFilterStringMatch

This filter allows or denies logging events if their message contains a given string.

Configurable parameters
ParameterRequiredDefault valueDescription
stringToMatchYes-The string to match.
acceptOnMatchNotrueIf set to true, the matching events are accepted, denied otherwise.
Example
<filter class="LoggerFilterStringMatch">
+

This configuration denies levels greater than WARN.

LoggerFilterStringMatch

This filter allows or denies logging events if their message contains a given string.

Configurable parameters
ParameterRequiredDefault valueDescription
stringToMatchYes-The string to match.
acceptOnMatchNotrueIf set to true, the matching events are accepted, denied otherwise.
Example
&
 lt;filter class="LoggerFilterStringMatch">
     <param name="StringToMatch" value="not-interesting" />
     <param name="AcceptOnMatch" value="false" />
 </filter>
@@ -217,7 +232,7 @@
                         Apache Software Foundation.
                   
         
-       Licensed under the Apache Software License, Version 2.0.

+ Licensed under the Apache Software License, Version 2.0. Please read the privacy policy

Apache log4php, Apache, log4php, the Apache feather logo, the Apache Logging Services project logo and the Built by Maven logo are trademarks of The Apache Software Foundation.