PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




openlog

Name

openlog — Opens a connection to the system logger.

Synopsis

bool openlog(ident, option, facility);
string ident: String to be prepended to the log message(s)
integer option: Integer flag representing one or more options
integer facility: Integer flag representing the type of program logging the error message(s)

Returns

TRUE

Description

openlog() opens a connection to the system logger. On UNIX-like systems, this is generally syslogd (run man syslogd for more information). On the Windows family of operating systems, this is the event log. Not all flavors of the Windows operating systems have the event log facility - see your system's help files and manual for more information.

Use of this function is optional. PHP automatically opens a connection to the system logger when syslog() is called. The advantage of using openlog() is that the developer gains extra control over how messages are logged.

Developers can choose a string to have prefixed to every entry written to the log using PHP's syslog() with the ident argument. Usually ident is used to identify the program that's logging the messages.

The behavior of the logging can be modified using the options and facility arguments. Both of these arguments are integer values; however, PHP provides named constants to make the task of setting them easier.

The following table lists the options that can be set. Note that more than one option can be set. Use the bitwise or (|) operator to join separate option constants into a single integer value (for example, LOG_CONS | LOG_NDELAY | LOG_PID).

Option Description
LOG_CONS Send error messages to the system console if the system logger is not available.
LOG_NDELAY Open the connection to the system log immediately.
LOG_ODELAY Open the connection to the system log when the first call to syslog() is made. This is the default setting.
LOG_PERROR Send error message to both stderr and the system log.
LOG_PID Write the PID of the script that generated the error in the system log.


Note

LOG_PID is the only valid option under Windows operating systems.

The facility argument tells the system logger what kind of program is logging a message. The system logger then decides what to do with the message based on how it's configured to handle the facility passed. The following table lists the types that can be set.

Facility Description
LOG_AUTH Security and authorization messages (deprecated on most systems - use LOG_AUTHPRIV instead)
LOG_AUTH_PRIV Private security and authorization messages
LOG_CRON Cron daemon
LOG_DAEMON Miscellaneous system daemons
LOG_KERN Kernel messages
LOG_LOCAL0 to LOG_LOCAL7 Reserved for local use
LOG_LPR Printer spool
LOG_MAIL Mail subsystem
LOG_NEWS News subsystem
LOG_SYSLOG Reserved for messages generated internally by syslogd
LOG_USER Miscellaneous user-level messages
LOG_UUCP UUCP subsystem


Note

LOG_USER is the only valid log type under Windows operating systems.

Version

PHP Version: 3+, 4+

Example

Example 1318. Open a connection to the system logger

openlog('PHP_Err: ', LOG_CONS | LOG_NDELAY | LOG_PID, LOG_USER)
    or die ('Syslog could not be opened');



PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.