| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <sect2 id="zend.log.writers.syslog">
- <title>Writing to the System Log</title>
- <para>
- <classname>Zend_Log_Writer_Syslog</classname> writes log entries to the
- system log (syslog). Internally, it proxies to <acronym>PHP</acronym>'s
- <methodname>openlog()</methodname>,
- <methodname>closelog()</methodname>, and
- <methodname>syslog()</methodname> functions.
- </para>
- <para>
- One useful case for <classname>Zend_Log_Writer_Syslog</classname>
- is for aggregating logs from clustered machines via the system log
- functionality. Many systems allow remote logging of system events, which
- allows system administrators to monitor a cluster of machines from a
- single log file.
- </para>
- <para>
- By default, all syslog messages generated are prefixed with the string
- "Zend_Log". You may specify a different "application" name by which to
- identify such log messages by either passing the application name to the
- constructor or the application accessor:
- </para>
- <programlisting language="php"><![CDATA[
- // At instantiation, pass the "application" key in the options:
- $writer = new Zend_Log_Writer_Syslog(array('application' => 'FooBar'));
- // Any other time:
- $writer->setApplicationName('BarBaz');
- ]]></programlisting>
- <para>
- The system log also allows you to identify the "facility," or
- application type, logging the message; many system loggers will actually
- generate different log files per facility, which again aids
- administrators monitoring server activity.
- </para>
- <para>
- You may specify the log facility either in the constructor or via an
- accessor. It should be one of the <methodname>openlog()</methodname>
- constants defined on the <ulink url="http://php.net/openlog">openlog()
- manual page</ulink>.
- </para>
- <programlisting language="php"><![CDATA[
- // At instantiation, pass the "facility" key in the options:
- $writer = new Zend_Log_Writer_Syslog(array('facility' => LOG_AUTH));
- // Any other time:
- $writer->setFacility(LOG_USER);
- ]]></programlisting>
- <para>
- When logging, you may continue to use the default
- <classname>Zend_Log</classname> priority constants; internally, they are
- mapped to the appropriate <methodname>syslog()</methodname> priority
- constants.
- </para>
- </sect2>
|