downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.openlog.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.network.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.openlog.php',
   
1 => 'openlog',
  ),
 
'up' =>
  array (
   
0 => 'ref.network.php',
   
1 => 'Network Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.long2ip.php',
   
1 => 'long2ip',
  ),
 
'next' =>
  array (
   
0 => 'function.pfsockopen.php',
   
1 => 'pfsockopen',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<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> &mdash; <span class="dc-title">Open connection to system logger</span></p>

 </div>
 
 <a name="function.openlog.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><b>openlog</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.php" class="function">syslog()</a> if
   necessary, in which case <i><tt class="parameter">ident</tt></i>
 will default
   to <b><tt class="constant">FALSE</tt></b>.
  </p>
 </div>


 <a name="function.openlog.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">ident</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The string <i><tt class="parameter">ident</tt></i>
 is added to each message.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">option</tt></i>
</span>

     </dt><dd class="listitem">

      <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.
       </p><table class="doctable table">
        <caption><b><b>openlog()</b> Options</b></caption>
       
         <thead valign="middle">
          <tr valign="middle">
           <th>Constant</th>
           <th>Description</th>
          </tr>

         </thead>

         <tbody valign="middle" class="tbody">
          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_CONS</tt></b></td>
           <td 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 align="left"><b><tt class="constant">LOG_NDELAY</tt></b></td>
           <td align="left">
            open the connection to the logger immediately
           </td>
          </tr>

          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_ODELAY</tt></b></td>
           <td align="left">
            (default) delay opening the connection until the first
            message is logged
           </td>
          </tr>

          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_PERROR</tt></b></td>
           <td align="left">print log message also to standard error</td>
          </tr>

          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_PID</tt></b></td>
           <td align="left">include PID with each message</td>
          </tr>

         </tbody>
       
       </table>
<p>
       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 class="varlistentry">

     <span class="term"><i><tt class="parameter">facility</tt></i>
</span>

     </dt><dd class="listitem">

      <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&#039;s syslog configuration) how messages coming from
       different facilities will be handled.
       </p><table class="doctable table">
        <caption><b><b>openlog()</b> Facilities</b></caption>
       
         <thead valign="middle">
          <tr valign="middle">
           <th>Constant</th>
           <th>Description</th>
          </tr>

         </thead>

         <tbody valign="middle" class="tbody">
          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_AUTH</tt></b></td>
           <td align="left">
            security/authorization messages (use
            <b><tt class="constant">LOG_AUTHPRIV</tt></b> instead
            in systems where that constant is defined)
           </td>
          </tr>

          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_AUTHPRIV</tt></b></td>
           <td align="left">security/authorization messages (private)</td>
          </tr>

          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_CRON</tt></b></td>
           <td align="left">clock daemon (cron and at)</td>
          </tr>

          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_DAEMON</tt></b></td>
           <td align="left">other system daemons</td>
          </tr>

          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_KERN</tt></b></td>
           <td align="left">kernel messages</td>
          </tr>

          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_LOCAL0</tt></b> ... <b><tt class="constant">LOG_LOCAL7</tt></b></td>
           <td align="left">reserved for local use, these are not available in Windows</td>
          </tr>

          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_LPR</tt></b></td>
           <td align="left">line printer subsystem</td>
          </tr>

          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_MAIL</tt></b></td>
           <td align="left">mail subsystem</td>
          </tr>

          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_NEWS</tt></b></td>
           <td align="left">USENET news subsystem</td>
          </tr>

          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_SYSLOG</tt></b></td>
           <td align="left">messages generated internally by syslogd</td>
          </tr>

          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_USER</tt></b></td>
           <td align="left">generic user-level messages</td>
          </tr>

          <tr valign="middle">
           <td align="left"><b><tt class="constant">LOG_UUCP</tt></b></td>
           <td align="left">UUCP subsystem</td>
          </tr>

         </tbody>
       
       </table>
<p>
      </p>
      <blockquote><p><b class="note">Note</b>:
      
        <b><tt class="constant">LOG_USER</tt></b> is the only valid log type under Windows
        operating systems
       <br />
      </p></blockquote>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.openlog.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <b><tt class="constant">TRUE</tt></b> on success or <b><tt class="constant">FALSE</tt></b> on failure.
  </p>
 </div>


 <a name="function.openlog.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.syslog.php" class="function" rel="rdfs-seeAlso">syslog()</a> - Generate a system log message</li>
    <li class="member"><a href="function.closelog.php" class="function" rel="rdfs-seeAlso">closelog()</a> - Close connection to system logger</li>
   </ul><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites