★ wanayoo — archive 1999 http://php.net/manual/ja/function.syslog.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to ネットワーク
Quick Reference
ネットワーク
English version of this pageGerman version of this pageJapanese version of this page
Italian version of this pageFrench version of this pageHungarian version of this page
Spanish version of this page
* checkdnsrr
* closelog
* debugger_off
* debugger_on
* define_syslog_variables
* fsockopen
* gethostbyaddr
* gethostbyname
* gethostbynamel
* getmxrr
* getprotobyname
* getprotobynumber
* getservbyname
* getservbyport
* ip2long
* long2ip
* openlog
* pfsockopen
* socket_set_blocking
* socket_set_timeout
* syslog

  Thanks to:
 Chek.com
 easyDNS
 VA Linux Systems

  Related sites:
Apache
MySQL
PostgreSQL
Zend Tech.

  Community:
LinuxFund.org
OSDN
Manual: syslog
View the source code for this pageSearch the site



Previous page
 socket_set_timeout
 Updated
Fri, 15 Sep 2000
ODBC 
Next page


syslog

(PHP3 <= 3.0.16, PHP4 )

syslog -- システムログのメッセージを生成する

説明

int syslog (int priority, string message)

syslog()はシステムログが出力するログメッセージを 生成します。priorityは、容易さ(facility)と レベル(level)の組み合わせで、その値については、次節で説明します。 残りの引数は送信するメッセージです。ただし、文字%m は、errnoの値に 対応するエラーメッセージ文字列(strerror)に置換されます。

表 1. syslog()の優先順位 (降順)

定数説明
LOG_EMERGシステムは使用不可
LOG_ALERTアクションを直ちにおこす必要がある
LOG_CRIT致命的な条件
LOG_ERRエラーを発生する条件
LOG_WARNING警告を発生する条件
LOG_NOTICE通常の動作だが、特徴的な条件
LOG_INFO情報を与えるメッセージ
LOG_DEBUGデバッグ用のメッセージ

例 1. syslog()の使用例


<?php
define_syslog_variables();
// syslogをオープンし、プロセスIDをインクルードし、標準エラー出力にも
// ログを出力します。そして、ユーザ定義のログ記録機構を使用します。
openlog("myScripLog", LOG_PID | LOG_PERROR, LOG_LOCAL0);

// 何らかのコード

if (authorized_client()) {
    // 何かをする
} else {
    // クライアントは未認証!
    // ログを記録する
    $access = date("Y/m/d H:i:s");
    syslog(LOG_WARNING,"Unauthorized client: $access $REMOTE_ADDR ($HTTP_USER_AGENT)");
}

closelog();
?>
      
ユーザ定義のログハンドラの設定に関する情報については、UNIXマニュ アルのsyslog.conf(5)を参照下さい。 syslog の facility と option に関するより詳細な情報は、 UNIXマシンのsyslog(3)にあります。

Windows NTでは、syslog サービスはイベントログを使用してエミュレー トされます。

define_syslog_variables(), openlog(), closelog()も参照下さい。


User Contributed Notes: syslog


bb@lb-data.co.at
08-Sep-1999 03:54
In Windows NT, use the following values of priority:
1 = error,
6 = info



fwo@obsidian.co.za
09-Dec-1999 09:59
The text was taken directly out of a unix man page. On a unix system do man 3 syslog and you wil get the info


rcgraves+php@brandeis.edu
17-Feb-2000 12:51
[I hope the HTML comes out right...]
For the-header-file-enabled:


man 3 syslog defines the priorities, but not the integer values. For that you'll need to read your system header file.


Let's suppose I want to log an informational message in the mail log (which happens to be true). The man page tells me I want LOG_MAIL|LOG_INFO. So I look in /usr/include/sys/syslog.h and find (this happens to be Linux, your system could be different):
<pre>
#define LOG_INFO 6 /* informational */
#define LOG_MAIL (2&lt;&lt;3) /* mail system */
</pre>
2&lt;&lt;3 means shift 3 bits left, which means multiply by 8. So I want 2*8 + 6 = 22. syslog(22,"this message will appear in the mail log"); And indeed it does.



fmajid@kefta.com
29-Apr-2000 02:43
Using PHP3, the documentation does not match the actual implementation.
To generate a syslog, I found the following code will work:


<PRE>
syslog("local7.info", "syslog message")
</PRE>
when the manual says the first argument should be an integer.



 About Notes


Previous page
 socket_set_timeout
 Updated
Fri, 15 Sep 2000
ODBC 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.