.\" Written Feb 1994 by Steve Greenland (stevegr@neosoft.com) .\" and Copyright 2001, 2017 Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" Updated 1999.12.19 by Karl M. Hegbloom .\" .\" Updated 13 Oct 2001, Michael Kerrisk .\" Added description of vsyslog .\" Added descriptions of LOG_ODELAY and LOG_NOWAIT .\" Added brief description of facility and option arguments .\" Added CONFORMING TO section .\" 2001-10-13, aeb, minor changes .\" Modified 13 Dec 2001, Martin Schulze .\" Modified 3 Jan 2002, Michael Kerrisk .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Translated Sep 1 20:14:01 JST 1996 .\" by Shoichi OZAWA .\" Updated Thu Oct 18 01:00:02 JST 2001 .\" by Akihiro MOTOKI .\" Updated Fri Jan 4 22:15:21 JST 2002 .\" by Akihiro MOTOKI .\" Updated 2002-04-14 by Kentaro Shirakata .\" Updated 2007-01-01 by Kentaro Shirakata .\" Updated 2012-05-29, Akihiro MOTOKI .\" Updated 2013-03-26, Akihiro MOTOKI .\" .TH SYSLOG 3 " 2017\-09\-15" Linux "Linux Programmer's Manual" .SH 名前 closelog, openlog, syslog, vsyslog \- システムロガーにメッセージを送る .SH 書式 \fB#include \fP .PP \fBvoid openlog(const char *\fP\fIident\fP\fB, int \fP\fIoption\fP\fB, int \fP\fIfacility\fP\fB);\fP .br \fBvoid syslog(int \fP\fIpriority\fP\fB, const char *\fP\fIformat\fP\fB, ...);\fP .br \fBvoid closelog(void);\fP .PP \fBvoid vsyslog(int \fP\fIpriority\fP\fB, const char *\fP\fIformat\fP\fB, va_list \fP\fIap\fP\fB);\fP .PP .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .RE .PP \fBvsyslog\fP(): Since glibc 2.19: _DEFAULT_SOURCE Glibc 2.19 and earlier: _BSD_SOURCE .SH 説明 .SS openlog() \fBopenlog\fP() は、プログラム用のシステムロガー (system logger) への接続をオープンする。 .PP \fIident\fP で指定した文字列は各メッセージの前に付与される。通常は \fIident\fP にはプログラム名が設定される。 \fIident\fP が NULL の場合、プログラムが \fIident\fP として使用される (POSIX.1\-2008 では \fIident\fP が NULL の場合の動作は規定されていない)。 .PP \fIoption\fP 引数は、 \fBopenlog\fP() の動作とその後の \fBsyslog\fP() の呼び出しを制御するフラグを指定する。 \fIfacility\fP 引数は、後で \fBsyslog\fP() を呼び出す際に facility が指定されなかった場合に使用される デフォルト値を決定する。 \fIoption\fP と \fIfacility\fP に指定できる値については後述する。 .PP .\" \fBopenlog\fP() は必須ではなく、必要に応じて \fBsyslog\fP() から呼び出される。 \fBsyslog\fP() が呼び出した場合、 \fIident\fP のデフォルト値は NULL になる。 .SS "syslog() と vsyslog()" \fBsyslog\fP() generates a log message, which will be distributed by \fBsyslogd\fP(8). .PP The \fIpriority\fP argument is formed by ORing together a \fIfacility\fP value and a \fIlevel\fP value (described below). If no \fIfacility\fP value is ORed into \fIpriority\fP, then the default value set by \fBopenlog\fP() is used, or, if there was no preceding \fBopenlog\fP() call, a default of \fBLOG_USER\fP is employed. .PP The remaining arguments are a \fIformat\fP, as in \fBprintf\fP(3), and any arguments required by the \fIformat\fP, except that the two\-character sequence \fB%m\fP will be replaced by the error message string \fIstrerror\fP(\fIerrno\fP). The format string need not include a terminating newline character. .PP .\" \fBvsyslog\fP() 関数は \fBsyslog\fP() と同じ機能を持つが、可変引数リストを指定することができる点が異なる。 指定された引数は、 \fBstdarg\fP(3) 可変引数リストマクロを用いて取得される。 .SS " closelog()" .\" \fBcloselog\fP() は、システムロガーに書き込むのに使用されるファイルディスクリプターをクローズする。 \fBcloselog\fP() の使用は必須ではない。 .SS "Values for \fIoption\fP" The \fIoption\fP argument to \fBopenlog\fP() is a bit mask constructed by ORing together any of the following values: .TP 15 \fBLOG_CONS\fP エラーがあれば、システムロガーに送る一方でシステムコンソールにも直接書く。 .TP \fBLOG_NDELAY\fP Open the connection immediately (normally, the connection is opened when the first message is logged). This may be useful, for example, if a subsequent \fBchroot\fP(2) would make the pathname used internally by the logging facility unreachable. .TP \fBLOG_NOWAIT\fP メッセージを記録する際に生成される子プロセスの終了を待たない。 (GNU C ライブラリは子プロセスを生成しない。 したがって、このオプションは Linux では無効である。) .TP \fBLOG_ODELAY\fP \fBLOG_NDELAY\fP の反対。 \fBsyslog\fP() が呼ばれるまで、接続の開始を行わない。 (このオプションはデフォルトであり、特に指定する必要はない。) .TP \fBLOG_PERROR\fP メッセージを \fIstderr\fP にも出力する。 (POSIX.1\-2001 にも POSIX.1\-2008 にも定義されていない) .TP \fBLOG_PID\fP .\" 個々のメッセージに呼び出し元の PID を含める。 .SS "Values for \fIfacility\fP" \fIfacility\fP 引数はメッセージに記録されるプログラムのタイプを指定するために使われる。 これによって異なるタイプのプログラムからのメッセージは異なる扱いを するように設定ファイル( \fBsyslog.conf\fP(5)) に定義できる。 .TP 15 \fBLOG_AUTH\fP セキュリティ/認証 メッセージ .TP \fBLOG_AUTHPRIV\fP セキュリティ/認証 メッセージ (プライベート) .TP \fBLOG_CRON\fP クロックデーモン (\fBcron\fP と at\fB)\fP .TP \fBLOG_DAEMON\fP 特定の facility 値を持たないシステムデーモン .TP \fBLOG_FTP\fP ftp デーモン .TP \fBLOG_KERN\fP .\" LOG_KERN has the value 0; if used as a facility, zero translates to: .\" "use the default facility". カーネルメッセージ (ユーザープロセスから生成することはできない) .TP \fBLOG_LOCAL0\fP から \fBLOG_LOCAL7\fP ローカルな使用のためにリザーブされている .TP \fBLOG_LPR\fP ラインプリンタサブシステム .TP \fBLOG_MAIL\fP メールサブシステム .TP \fBLOG_NEWS\fP USENET ニュースサブシステム .TP \fBLOG_SYSLOG\fP \fBsyslogd\fP(8) によって内部的に発行されるメッセージ .TP \fBLOG_USER\fP (デフォルト) 一般的なユーザーレベルメッセージ .TP \fBLOG_UUCP\fP .\" UUCPサブシステム .SS "Values for \fIlevel\fP" これはメッセージの優先度を指定する。 優先度の高いものから低いものの順で下記する。 .TP 15 \fBLOG_EMERG\fP システムが使用不可 .TP \fBLOG_ALERT\fP 直ちに行動を起こさなければならない .TP \fBLOG_CRIT\fP 危険な状態 .TP \fBLOG_ERR\fP エラーの状態 .TP \fBLOG_WARNING\fP ワーニングの状態 .TP \fBLOG_NOTICE\fP 通常だが重要な状態 .TP \fBLOG_INFO\fP インフォメーションメッセージ .TP \fBLOG_DEBUG\fP デバッグレベルのメッセージ .PP \fBsetlogmask\fP(3) 関数を使用して、 指定されたレベルのメッセージだけを記録するように 制限することができる。 .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lbw21 lb lb l l l. インターフェース 属性 値 T{ \fBopenlog\fP(), \fBcloselog\fP() T} Thread safety MT\-Safe T{ \fBsyslog\fP(), \fBvsyslog\fP() T} Thread safety MT\-Safe env locale .TE .SH 準拠 \fBopenlog\fP(), \fBcloselog\fP(), \fBsyslog\fP() は SUSv2, POSIX.1\-2001, POSIX.1\-2008 で規定されている (但し \fBvsyslog\fP() は除く)。 .PP POSIX.1\-2001 では \fIfacility\fP として \fBLOG_USER\fP と \fBLOG_LOCAL*\fP の値が規定されているだけである。 しかしながら、 \fBLOG_AUTHPRIV\fP と \fBLOG_FTP\fP という例外はあるが、 それ以外の \fIfacility\fP の値は多くの UNIX システムで使われている。 .PP .\" .SH HISTORY .\" A .\" .BR syslog () .\" function call appeared in 4.2BSD. .\" 4.3BSD documents .\" .BR openlog (), .\" .BR syslog (), .\" .BR closelog (), .\" and .\" .BR setlogmask (). .\" 4.3BSD-Reno also documents .\" .BR vsyslog (). .\" Of course early v* functions used the .\" .I .\" mechanism, which is not compatible with .\" .IR . \fIoption\fP の値の \fBLOG_PERROR\fP の値は、 POSIX.1\-2001 と POSIX.1\-2008 では規定されていないが、 UNIX の多くのバージョンで使用可能である。 .SH 注意 \fBopenlog\fP() 呼び出しの \fIident\fP 引数は、値がそのまま保持されていることを前提にしている。 それゆえ、 \fIident\fP で指定された文字列が変更されると、 \fBsyslog\fP() は変更された文字列の追加するだろうし、 指定された文字列が存在しなくなった場合、結果は未定義である。 最も移植性がある方法は、文字列定数を使用することである。 .PP ユーザーから与えられたデータを format として渡してはならない。 代わりに以下を使うこと。 .PP .in +4n .EX syslog(priority, "%s", string); .EE .in .SH 関連項目 \fBjournalctl\fP(1), \fBlogger\fP(1), \fBsetlogmask\fP(3), \fBsyslog.conf\fP(5), \fBsyslogd\fP(8) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。