📄 function.openlog.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Open connection to system logger</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div 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"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>openlog</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$ident</tt></span> , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$option</tt></span> , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$facility</tt></span> )</div> <p class="para rdfs-comment"> <b>openlog()</b> opens a connection to the system logger for a program. </p> <p class="para"> The use of <b>openlog()</b> is optional. It will automatically be called by <a href="function.syslog.html" class="function">syslog()</a> if necessary, in which case <i><tt class="parameter">ident</tt></i> will default to <b><tt>FALSE</tt></b>. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">ident</tt></i></span> <dd> <p class="para"> The string <i><tt class="parameter">ident</tt></i> is added to each message. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">option</tt></i></span> <dd> <p class="para"> The <i><tt class="parameter">option</tt></i> argument is used to indicate what logging options will be used when generating a log message. <table border="5"> <caption><b><b>openlog()</b> Options</b></caption> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Constant</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_CONS</tt></b></td> <td colspan="1" rowspan="1" align="left"> if there is an error while sending data to the system logger, write directly to the system console </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_NDELAY</tt></b></td> <td colspan="1" rowspan="1" align="left"> open the connection to the logger immediately </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_ODELAY</tt></b></td> <td colspan="1" rowspan="1" align="left"> (default) delay opening the connection until the first message is logged </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_PERROR</tt></b></td> <td colspan="1" rowspan="1" align="left">print log message also to standard error</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_PID</tt></b></td> <td colspan="1" rowspan="1" align="left">include PID with each message</td> </tr> </tbody> </colgroup> </table> You can use one or more of this options. When using multiple options you need to <i>OR</i> them, i.e. to open the connection immediately, write to the console and include the PID in each message, you will use: <i>LOG_CONS | LOG_NDELAY | LOG_PID</i> </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">facility</tt></i></span> <dd> <p class="para"> The <i><tt class="parameter">facility</tt></i> 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 border="5"> <caption><b><b>openlog()</b> Facilities</b></caption> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Constant</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_AUTH</tt></b></td> <td colspan="1" rowspan="1" align="left"> security/authorization messages (use <b><tt>LOG_AUTHPRIV</tt></b> instead in systems where that constant is defined) </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_AUTHPRIV</tt></b></td> <td colspan="1" rowspan="1" align="left">security/authorization messages (private)</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_CRON</tt></b></td> <td colspan="1" rowspan="1" align="left">clock daemon (cron and at)</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_DAEMON</tt></b></td> <td colspan="1" rowspan="1" align="left">other system daemons</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_KERN</tt></b></td> <td colspan="1" rowspan="1" align="left">kernel messages</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_LOCAL0</tt></b> ... <b><tt>LOG_LOCAL7</tt></b></td> <td colspan="1" rowspan="1" align="left">reserved for local use, these are not available in Windows</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_LPR</tt></b></td> <td colspan="1" rowspan="1" align="left">line printer subsystem</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_MAIL</tt></b></td> <td colspan="1" rowspan="1" align="left">mail subsystem</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_NEWS</tt></b></td> <td colspan="1" rowspan="1" align="left">USENET news subsystem</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_SYSLOG</tt></b></td> <td colspan="1" rowspan="1" align="left">messages generated internally by syslogd</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_USER</tt></b></td> <td colspan="1" rowspan="1" align="left">generic user-level messages</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>LOG_UUCP</tt></b></td> <td colspan="1" rowspan="1" align="left">UUCP subsystem</td> </tr> </tbody> </colgroup> </table> </p> <blockquote><p><b class="note">Note</b>: <b><tt>LOG_USER</tt></b> is the only valid log type under Windows operating systems <br /> </p></blockquote> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure. </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.define-syslog-variables.html" class="function" rel="rdfs-seeAlso">define_syslog_variables()</a></li> <li class="member"><a href="function.syslog.html" class="function" rel="rdfs-seeAlso">syslog()</a></li> <li class="member"><a href="function.closelog.html" class="function" rel="rdfs-seeAlso">closelog()</a></li> </ul> </p> </div></div><hr /><div 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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -