Zend_Log-Writers-Syslog.xml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect2 id="zend.log.writers.syslog">
  4. <title>Writing to the System Log</title>
  5. <para>
  6. <classname>Zend_Log_Writer_Syslog</classname> writes log entries to the
  7. system log (syslog). Internally, it proxies to <acronym>PHP</acronym>'s
  8. <methodname>openlog()</methodname>,
  9. <methodname>closelog()</methodname>, and
  10. <methodname>syslog()</methodname> functions.
  11. </para>
  12. <para>
  13. One useful case for <classname>Zend_Log_Writer_Syslog</classname>
  14. is for aggregating logs from clustered machines via the system log
  15. functionality. Many systems allow remote logging of system events, which
  16. allows system administrators to monitor a cluster of machines from a
  17. single log file.
  18. </para>
  19. <para>
  20. By default, all syslog messages generated are prefixed with the string
  21. "Zend_Log". You may specify a different "application" name by which to
  22. identify such log messages by either passing the application name to the
  23. constructor or the application accessor:
  24. </para>
  25. <programlisting language="php"><![CDATA[
  26. // At instantiation, pass the "application" key in the options:
  27. $writer = new Zend_Log_Writer_Syslog(array('application' => 'FooBar'));
  28. // Any other time:
  29. $writer->setApplicationName('BarBaz');
  30. ]]></programlisting>
  31. <para>
  32. The system log also allows you to identify the "facility," or
  33. application type, logging the message; many system loggers will actually
  34. generate different log files per facility, which again aids
  35. administrators monitoring server activity.
  36. </para>
  37. <para>
  38. You may specify the log facility either in the constructor or via an
  39. accessor. It should be one of the <methodname>openlog()</methodname>
  40. constants defined on the <ulink url="http://php.net/openlog">openlog()
  41. manual page</ulink>.
  42. </para>
  43. <programlisting language="php"><![CDATA[
  44. // At instantiation, pass the "facility" key in the options:
  45. $writer = new Zend_Log_Writer_Syslog(array('facility' => LOG_AUTH));
  46. // Any other time:
  47. $writer->setFacility(LOG_USER);
  48. ]]></programlisting>
  49. <para>
  50. When logging, you may continue to use the default
  51. <classname>Zend_Log</classname> priority constants; internally, they are
  52. mapped to the appropriate <methodname>syslog()</methodname> priority
  53. constants.
  54. </para>
  55. </sect2>