<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Open connection to system logger</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.long2ip.html">long2ip</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pfsockopen.html">pfsockopen</a></div> <div class="up"><a href="ref.network.html">Network Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.openlog" class="refentry"> <div class="refnamediv"> <h1 class="refname">openlog</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">openlog</span> — <span class="dc-title">Open connection to system logger</span></p> </div> <div class="refsect1 description" id="refsect1-function.openlog-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><strong>openlog</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$ident</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$option</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$facility</code></span> )</div> <p class="para rdfs-comment"> <span class="function"><strong>openlog()</strong></span> opens a connection to the system logger for a program. </p> <p class="para"> The use of <span class="function"><strong>openlog()</strong></span> is optional. It will automatically be called by <span class="function"><a href="function.syslog.html" class="function">syslog()</a></span> if necessary, in which case <em><code class="parameter">ident</code></em> will default to <strong><code>FALSE</code></strong>. </p> </div> <div class="refsect1 parameters" id="refsect1-function.openlog-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">ident</code></em></span> <dd> <p class="para"> The string <em><code class="parameter">ident</code></em> is added to each message. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">option</code></em></span> <dd> <p class="para"> The <em><code class="parameter">option</code></em> argument is used to indicate what logging options will be used when generating a log message. <table class="doctable table"> <caption><strong> <span class="function"><strong>openlog()</strong></span> Options</strong></caption> <thead> <tr> <th>Constant</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td><strong><code>LOG_CONS</code></strong></td> <td> if there is an error while sending data to the system logger, write directly to the system console </td> </tr> <tr> <td><strong><code>LOG_NDELAY</code></strong></td> <td> open the connection to the logger immediately </td> </tr> <tr> <td><strong><code>LOG_ODELAY</code></strong></td> <td> (default) delay opening the connection until the first message is logged </td> </tr> <tr> <td><strong><code>LOG_PERROR</code></strong></td> <td>print log message also to standard error</td> </tr> <tr> <td><strong><code>LOG_PID</code></strong></td> <td>include PID with each message</td> </tr> </tbody> </table> You can use one or more of this options. When using multiple options you need to <em>OR</em> them, i.e. to open the connection immediately, write to the console and include the PID in each message, you will use: <em>LOG_CONS | LOG_NDELAY | LOG_PID</em> </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">facility</code></em></span> <dd> <p class="para"> The <em><code class="parameter">facility</code></em> argument 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. <table class="doctable table"> <caption><strong> <span class="function"><strong>openlog()</strong></span> Facilities</strong></caption> <thead> <tr> <th>Constant</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td><strong><code>LOG_AUTH</code></strong></td> <td> security/authorization messages (use <strong><code>LOG_AUTHPRIV</code></strong> instead in systems where that constant is defined) </td> </tr> <tr> <td><strong><code>LOG_AUTHPRIV</code></strong></td> <td>security/authorization messages (private)</td> </tr> <tr> <td><strong><code>LOG_CRON</code></strong></td> <td>clock daemon (cron and at)</td> </tr> <tr> <td><strong><code>LOG_DAEMON</code></strong></td> <td>other system daemons</td> </tr> <tr> <td><strong><code>LOG_KERN</code></strong></td> <td>kernel messages</td> </tr> <tr> <td><strong><code>LOG_LOCAL0</code></strong> ... <strong><code>LOG_LOCAL7</code></strong></td> <td>reserved for local use, these are not available in Windows</td> </tr> <tr> <td><strong><code>LOG_LPR</code></strong></td> <td>line printer subsystem</td> </tr> <tr> <td><strong><code>LOG_MAIL</code></strong></td> <td>mail subsystem</td> </tr> <tr> <td><strong><code>LOG_NEWS</code></strong></td> <td>USENET news subsystem</td> </tr> <tr> <td><strong><code>LOG_SYSLOG</code></strong></td> <td>messages generated internally by syslogd</td> </tr> <tr> <td><strong><code>LOG_USER</code></strong></td> <td>generic user-level messages</td> </tr> <tr> <td><strong><code>LOG_UUCP</code></strong></td> <td>UUCP subsystem</td> </tr> </tbody> </table> </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> <strong><code>LOG_USER</code></strong> is the only valid log type under Windows operating systems </p> </p></blockquote> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.openlog-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 seealso" id="refsect1-function.openlog-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.syslog.html" class="function" rel="rdfs-seeAlso">syslog()</a> - Generate a system log message</span></li> <li class="member"> <span class="function"><a href="function.closelog.html" class="function" rel="rdfs-seeAlso">closelog()</a> - Close connection to system logger</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.long2ip.html">long2ip</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pfsockopen.html">pfsockopen</a></div> <div class="up"><a href="ref.network.html">Network Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>