OSDN Git Service

Translation snapshot of stdio of 3.76
[linuxjm/LDP_man-pages.git] / draft / man2 / syslog.2
1 .\" t
2 .\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
3 .\" and Copyright (C) 2012, 2014 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\"
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" %%%LICENSE_END
26 .\"
27 .\" Written 11 June 1995 by Andries Brouwer <aeb@cwi.nl>
28 .\" 2008-02-15, Jeremy Kerr <jk@ozlabs.org>
29 .\"     Add info on command type 10; add details on types 6, 7, 8, & 9.
30 .\" 2008-02-15, Michael Kerrisk <mtk.manpages@gmail.com>
31 .\"     Update LOG_BUF_LEN details; update RETURN VALUE section.
32 .\"
33 .\"*******************************************************************
34 .\"
35 .\" This file was generated with po4a. Translate the source file.
36 .\"
37 .\"*******************************************************************
38 .\"
39 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
40 .\"         all rights reserved.
41 .\" Translated Mon Dec 16 11:16:34 JST 2001
42 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
43 .\" Updated Thu Mar 6 2003 by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
44 .\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
45 .\" Updated 2008-04-04, Akihiro MOTOKI, LDP v2.79
46 .\" Updated 2008-07-31, Akihiro MOTOKI, LDP v3.05
47 .\" Updated 2012-04-30, Akihiro MOTOKI <amotoki@gmail.com>
48 .\" Updated 2012-05-29, Akihiro MOTOKI <amotoki@gmail.com>
49 .\" Updated 2013-05-06, Akihiro MOTOKI <amotoki@gmail.com>
50 .\"
51 .TH SYSLOG 2 2014\-07\-08 Linux "Linux Programmer's Manual"
52 .SH 名前
53 syslog, klogctl \- カーネルのメッセージ・リング・バッファを読んだり消去したりする; console_loglevel の設定を行う
54 .SH 書式
55 .nf
56 \fBint syslog(int \fP\fItype\fP\fB, char *\fP\fIbufp\fP\fB, int \fP\fIlen\fP\fB);\fP
57 \fB/* glibc ではラッパー関数は提供されていない */\fP
58 .sp
59 /* glibc のインタフェース */
60 .br
61 \fB#include <sys/klog.h>\fP
62 .sp
63 \fBint klogctl(int \fP\fItype\fP\fB, char *\fP\fIbufp\fP\fB, int \fP\fIlen\fP\fB);\fP
64 .fi
65 .SH 説明
66 \fI注意\fP: おそらく、あなたが探しているのは、 \fBsyslogd\fP(8) と通信する C ライブラリ関数の \fBsyslog\fP() でしょう。詳細は
67 \fBsyslog\fP(3) を参照のこと。
68
69 このページはカーネルの \fBsyslog\fP() システムコールについて説明している。 \fBsyslog\fP() システムコールはカーネルの
70 \fIprintk\fP() バッファを制御するために使用される。 このシステムコールに対する glibc ラッパー関数は \fBklogctl\fP()
71 と呼ばれている。
72 .SS "カーネル・ログ・バッファ (kernel log buffer)"
73 .\" Under "General setup" ==> "Kernel log buffer size"
74 .\" For 2.6, precisely the option seems to have appeared in 2.5.55.
75 カーネルは長さ \fBLOG_BUF_LEN\fP の巡回式のバッファを持っており、 それにはカーネル関数の \fBprintk\fP()
76 の引き数として与えられた メッセージが (そのログレベルにかかわらず) 格納される。 初期のカーネルでは \fBLOG_BUF_LEN\fP の値は 4096
77 であった。 カーネル 1.3.54 からは 8192、 カーネル 2.1.113 からは 16384 になり、 カーネル 2.4.23 以降および
78 2.6 以降ではカーネル設定オプション (\fBCONFIG_LOG_BUF_SHIFT\fP、 デフォルト値はアーキテクチャー依存)
79 で値を設定できるようになっている。 Linux 2.6.6 以降では、コマンド 10 (下記参照) でバッファのサイズを問い合わせできる。
80 .SS コマンド
81 \fItype\fP 引き数はこの関数が行う動作を決定する。 以下のリストに示す値を \fItype\fP に指定できる。
82 シンボル名はカーネルソースで定義されているが、ユーザ空間には公開されていない。 したがって、数字を使うか、名前を自分で定義する必要がある。
83 .TP 
84 \fBSYSLOG_ACTION_CLOSE\fP (0)
85 ログをクローズする。現在のところ NOP である。
86 .TP 
87 \fBSYSLOG_ACTION_OPEN\fP (1)
88 ログをオープンする。現在のところ NOP である。
89 .TP 
90 \fBSYSLOG_ACTION_READ\fP (2)
91 ログを読み出す。 この呼び出しは、 カーネル・ログ・バッファが空でなくなるまで待って、 最大 \fIlen\fP バイトまで \fIbufp\fP
92 が指すバッファに読み込み、 読み込んだバイト数を返す。 ログから読まれたバイトはログ・バッファから消える。 つまり、情報は一度しか読むことができない。
93 これはユーザーのプログラムが \fI/proc/kmsg\fP を読んだ時にカーネルによって実行される関数でもある。
94 .TP 
95 \fBSYSLOG_ACTION_READ_ALL\fP (3)
96 リング・バッファに残っているメッセージをすべて読み出し、 \fIbufp\fP が指すバッファに格納する。 この呼び出しログ・バッファの最後の \fIlen\fP
97 バイトを (非破壊的に) 読み出すが、 最後の「リング・バッファ消去」命令 (下記のコマンド 5 参照)
98 以降にバッファに書き込まれた情報しか読み出せない。 返り値は読み込んだバイト数である。
99 .TP 
100 \fBSYSLOG_ACTION_READ_CLEAR\fP (4)
101 リング・バッファに残っているメッセージをすべて読み出し、クリアする。 この呼び出しは \fItype\fP 3
102 と全く同じことを行い、追加で「リング・バッファ消去」 ("clear ring buffer") コマンドも実行する。
103 .TP 
104 \fBSYSLOG_ACTION_CLEAR\fP (5)
105 「リング・バッファ消去」 (\"clear ring buffer\") コマンドのみを実行する。 引き数 \fIbufp\fP と \fIlen\fP
106 は無視される。
107 .IP
108 このコマンドは実際にリング・バッファをクリアするわけではなく、 コマンド 3 (\fBSYSLOG_ACTION_READ_ALL\fP) と 4
109 (\fBSYSLOG_ACTION_READ_CLEAR\fP で返す内容を決定するカーネルの管理変数を設定する。 このコマンドはコマンド 2
110 (\fBSYSLOG_ACTION_READ\fP) と 9 (\fBSYSLOG_ACTION_SIZE_UNREAD\fP) には影響を与えない。
111 .TP 
112 \fBSYSLOG_ACTION_CONSOLE_OFF\fP (6)
113 .\" commit 1aaad49e856ce41adc07d8ae0c8ef35fc4483245
114 The command saves the current value of \fIconsole_loglevel\fP and then sets
115 \fIconsole_loglevel\fP to \fIminimum_console_loglevel\fP, so that no messages are
116 printed to the console.  Before Linux 2.6.32, the command simply sets
117 \fIconsole_loglevel\fP to \fIminimum_console_loglevel\fP.  See the discussion of
118 \fI/proc/sys/kernel/printk\fP, below.
119
120 引き数 \fIbufp\fP と \fIlen\fP は無視される。
121 .TP 
122 \fBSYSLOG_ACTION_CONSOLE_ON\fP (7)
123 .\" commit 1aaad49e856ce41adc07d8ae0c8ef35fc4483245
124 If a previous \fBSYSLOG_ACTION_CONSOLE_OFF\fP command has been performed, this
125 command restores \fIconsole_loglevel\fP to the value that was saved by that
126 command.  Before Linux 2.6.32, this command simply sets \fIconsole_loglevel\fP
127 to \fIdefault_console_loglevel\fP.  See the discussion of
128 \fI/proc/sys/kernel/printk\fP, below.
129
130 引き数 \fIbufp\fP と \fIlen\fP は無視される。
131 .TP 
132 \fBSYSLOG_ACTION_CONSOLE_LEVEL\fP (8)
133 \fIconsole_loglevel\fP を \fIlen\fP で指定された値に設定する。 \fIlen\fP は 1 以上 8 以下の整数でなければならない。
134 カーネルにより、暗黙のうちに \fIlen\fP に \fIminimum_console_loglevel\fP で指定される最小値が適用される。
135 詳細は「ログレベル」の節を参照のこと。 引き数 \fIbufp\fP は無視される。
136 .TP 
137 \fBSYSLOG_ACTION_SIZE_UNREAD\fP (9) (Linux 2.4.10 以降)
138 コマンド 2 (\fBSYSLOG_ACTION_READ\fP) でカーネル・ログ・バッファから読み出せるバイト数を返す。 引き数 \fIbufp\fP と
139 \fIlen\fP は無視される。
140 .TP 
141 \fBSYSLOG_ACTION_SIZE_BUFFER\fP (10) (Linux 2.6.6 以降)
142 カーネル・ログ・バッファの全体のサイズを返す。 引き数 \fIbufp\fP と \fIlen\fP は無視される。
143 .PP
144 .\"
145 .\"
146 コマンド種別 3 と 10 以外のコマンドは全て特権が必要である。
147 バージョン 2.6.37 より前の Linux カーネルでは、
148 コマンド種別 3 と 10 は非特権プロセスも呼び出すことができる。
149 Linux 2.6.37 以降では、\fI/proc/sys/kernel/dmesg_restrict\fP が値 0 の場合に限り、
150 非特権プロセスはこれらのコマンドを呼び出すことができる。
151 Linux 2.6.37 より前では、「特権を持つ (privileged)」とは呼び出し者が
152 \fBCAP_SYS_ADMIN\fP ケーパビリティを持つことを意味する。
153 Linux 2.6.37 以降では、「特権を持つ」とは呼び出し者が
154 \fBCAP_SYS_ADMIN\fP ケーパビリティか
155 (新しい) \fBCAP_SYSLOG\fP ケーパビリティのいずれかを持つことを意味する
156 (この目的で \fBCAP_SYS_ADMIN\fP ケーパビリティを使うのは今は非推奨である)。
157 .SS /proc/sys/kernel/printk
158 \fI/proc/sys/kernel/printk\fP is a writable file containing four integer values
159 that influence kernel \fIprintk()\fP behavior when printing or logging error
160 messages.  The four values are:
161 .TP 
162 \fIconsole_loglevel\fP
163 .\" since Linux 2.4
164 メッセージのログレベルがこの値よりも小さい場合のみ、メッセージだけがコンソールに出力される。 このフィールドのデフォルト値は
165 \fBDEFAULT_CONSOLE_LOGLEVEL\fP (7) だが、 カーネルのコマンドラインに "quiet" という単語が含まれている場合は 4
166 に設定され、 "debug" という単語が含まれている場合は 10 に設定され、 カーネルフォールトが発生した場合には 15 に設定される (但し、10
167 や 15 という数字に意味はなく、8 と同等である)。 \fIconsole_loglevel\fP の値は \fItype\fP が 8 の
168 \fBsyslog\fP() の呼び出しによって設定でき、 設定できる値の範囲は 1\-8 である。
169 .TP 
170 \fIdefault_message_loglevel\fP
171 .\" commit 5af5bcb8d37f99ba415a1adc6da71051b84f93a5
172 This value will be used as the log level for \fIprintk()\fP messages that do
173 not have an explicit level.  Up to and including Linux 2.6.38, the
174 hard\-coded default value for this field was 4 (\fBKERN_WARNING\fP); since Linux
175 2.6.39, the default value is a defined by the kernel configuration option
176 \fBCONFIG_DEFAULT_MESSAGE_LOGLEVEL\fP, which defaults to 4.
177 .TP 
178 \fIminimum_console_loglevel\fP
179 The value in this field is the minimum value to which \fIconsole_loglevel\fP
180 can be set.
181 .TP 
182 \fIdefault_console_loglevel\fP
183 .\"
184 .\"
185 This is the default value for \fIconsole_loglevel\fP.
186 .SS ログレベル
187 Every \fIprintk\fP()  message has its own log level.  If the log level is not
188 explicitly specified as part of the message, it defaults to
189 \fIdefault_message_loglevel\fP.  The conventional meaning of the log level is
190 as follows:
191
192 .TS
193 lB lB lB
194 lB c l.
195 カーネル定数      レベル値    意味
196 KERN_EMERG      0       システムが使用不可
197 KERN_ALERT      1       直ちに対応しなければならない
198 KERN_CRIT       2       危険な状況
199 KERN_ERR        3       エラー状況
200 KERN_WARNING    4       警告状況
201 KERN_NOTICE     5       通常だが重要な状況
202 KERN_INFO       6       参考情報
203 KERN_DEBUG      7       デバッグレベルのメッセージ
204 .TE
205
206 The kernel \fIprintk()\fP routine will print a message on the console only if
207 it has a log level less than the value of \fIconsole_loglevel\fP.
208 .SH 返り値
209 \fItype\fP が 2, 3, 4 の場合、成功すると \fBsyslog\fP()  は読み出したバイト数を返す。 \fItype\fP が 9 の場合、
210 カーネル・ログ・バッファにある現在読み出し可能なバイト数を返す。 \fItype\fP が 10 の場合、 カーネル・ログ・バッファの総量を返す。
211 \fItype\fP がそれ以外の値の場合、成功すると 0 が返される。
212
213 エラーの場合は、\-1\ が返り、 \fIerrno\fP にエラーを示す値が設定される。
214 .SH エラー
215 .TP 
216 \fBEINVAL\fP
217 不正な引き数 (具体的には、 \fItype\fP が正しくない、もしくは \fItype\fP が 2, 3, 4 の場合に \fIbuf\fP が NULL か
218 \fIlen\fP が 0 未満である、もしくは \fItype\fP が 8 の場合に \fIlevel\fP が 1 以上 8 以下の範囲に入っていない)。
219 .TP 
220 \fBENOSYS\fP
221 カーネルの設定オプション \fBCONFIG_PRINTK\fP を無効にしてカーネルがコンパイルされているため、 \fBsyslog\fP()
222 システムコールが利用できない。
223 .TP 
224 \fBEPERM\fP
225 十分な権限を持たないプロセス (正確にはケーパビリティ \fBCAP_SYS_ADMIN\fP も \fBCAP_SYSLOG\fP も持たないプロセス) が
226 \fIconsole_loglevel\fP を変更しようとしたか、 カーネル・メッセージ・リングを消去しようとした。
227 .TP 
228 \fBERESTARTSYS\fP
229 システム・コールがシグナルによって割り込まれ、何も読み出せなかった。 (トレース中にしか発生することはない)
230 .SH 準拠
231 このシステム・コールは Linux 特有であり、移植を意図したプログラムでは 使用してはいけない。
232 .SH 注意
233 .\" In libc4 and libc5 the number of this call was defined by
234 .\" .BR SYS_klog .
235 .\" In glibc 2.0 the syscall is baptized
236 .\" .BR klogctl ().
237 かなり初期の頃から、同じ名前を持つシステムコールとライブラリルーチンが
238 全く異なる別物であるのは不幸なことだと指摘されてきた。
239 .SH 関連項目
240 \fBsyslog\fP(3), \fBcapabilities\fP(7)
241 .SH この文書について
242 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.76 の一部
243 である。プロジェクトの説明とバグ報告に関する情報は
244 http://www.kernel.org/doc/man\-pages/ に書かれている。