1 .\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Written 11 June 1995 by Andries Brouwer <aeb@cwi.nl>
24 .\" 2008-02-15, Jeremy Kerr <jk@ozlabs.org>
25 .\" Add info on command type 10; add details on types 6, 7, 8, & 9.
26 .\" 2008-02-15, Michael Kerrisk <mtk.manpages@gmail.com>
27 .\" Update LOG_BUF_LEN details; update RETURN VALUE section.
29 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
30 .\" all rights reserved.
31 .\" Translated Mon Dec 16 11:16:34 JST 2001
32 .\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
33 .\" Updated Thu Mar 6 2003 by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
34 .\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
35 .\" Updated 2008-04-04, Akihiro MOTOKI, LDP v2.79
36 .\" Updated 2008-07-31, Akihiro MOTOKI, LDP v3.05
39 .\"WORD: message ring buffer メッセージ・リング・バッファ
40 .\"WORD: library ライブラリ
41 .\"WORD: kernel log buffer カーネル・ログ・バッファ
42 .\"WORD: console コンソール
43 .\"WORD: kernel panic カーネル・パニック
44 .\"WORD: loglevel ログレベル
45 .\"WORD: debug message デバッグ・メッセージ
47 .TH SYSLOG 2 2008-06-20 "Linux" "Linux Programmer's Manual"
50 .\"O syslog, klogctl \- read and/or clear kernel message ring buffer;
51 .\"O set console_loglevel
52 syslog, klogctl \- カーネルのメッセージ・リング・バッファを読んだり消去したりする;
53 console_loglevel の設定を行う
57 .BI "int syslog(int " type ", char *" bufp ", int " len );
58 .\"O .B " /* No wrapper provided in glibc */"
59 .B " /* glibc ではラッパー関数は提供されていない */"
61 .\"O /* The glibc interface */
64 .B "#include <sys/klog.h>"
66 .BI "int klogctl(int " type ", char *" bufp ", int " len );
70 .\"O If you need the C library function
73 .\"O .BR syslogd (8)),
76 .\"O The system call of this name is about controlling the kernel
78 .\"O buffer, and the glibc version is called
88 バッファを制御するものであり、glibc では
92 .\"O .The \fItype\fP argument determines the action taken by this function.
93 \fItype\fP 引き数はこの関数の動作を決定する。
96 .\"O .IR kernel/printk.c :
101 .\"O * Commands to sys_syslog:
103 .\"O * 0 \-\- Close the log. Currently a NOP.
104 .\"O * 1 \-\- Open the log. Currently a NOP.
105 .\"O * 2 \-\- Read from the log.
106 .\"O * 3 \-\- Read all messages remaining in the ring buffer.
107 .\"O * 4 \-\- Read and clear all messages remaining in the ring buffer
108 .\"O * 5 \-\- Clear ring buffer.
109 .\"O * 6 \-\- Disable printk to console
110 .\"O * 7 \-\- Enable printk to console
111 .\"O * 8 \-\- Set level of messages printed to console
112 .\"O * 9 \-\- Return number of unread characters in the log buffer
113 .\"O * 10 \-\- Return size of the log buffer
116 * Commands to sys_syslog:
118 * 0 \-\- ログを閉じる。現在の実装では何もしない (NOP) 。
119 * 1 \-\- ログを開く。現在の実装では何もしない (NOP) 。
121 * 3 \-\- リング・バッファに残っているメッセージをすべて読み出す。
122 * 4 \-\- リング・バッファに残っているメッセージをすべて読み出し、消去する。
123 * 5 \-\- リングバッファを消去する。
124 * 6 \-\- コンソールへの printk を無効にする。
125 * 7 \-\- コンソールへの printk を有効にする。
126 * 8 \-\- コンソールに表示されるメッセージのレベルを設定する。
127 * 9 \-\- ログバッファの未読の文字数を返す。
128 * 10 \-\- ログバッファのサイズを返す。
132 .\"O Only command types 3 and 10 are allowed to unprivileged processes.
133 .\"O Type 9 was added in 2.4.10; type 10 in 2.6.6.
134 非特権プロセスにはコマンド 3 と 10 のみが許可されている
135 (コマンド 9 は Linux 2.4.10 で、コマンド 10 は Linux 2.6.6 で追加された)。
136 .\"O .SS The kernel log buffer
137 .SS カーネル・ログ・バッファ (kernel log buffer)
138 .\"O The kernel has a cyclic buffer of length
140 .\"O in which messages given as arguments to the kernel function
142 .\"O are stored (regardless of their loglevel).
143 .\"O In early kernels,
145 .\"O had the value 4096;
146 .\"O from kernel 1.3.54, it was 8192;
147 .\"O from kernel 2.1.113 it was 16384;
148 .\"O since 2.4.23/2.6 the value is a kernel configuration option.
149 .\"O .\" Under "General setup" ==> "Kernel log buffer size"
150 .\"O .\" For 2.6, precisely the option seems to have appeared in 2.5.55.
151 .\"O In recent kernels the size can be queried with command type 10.
158 メッセージが (そのログレベルにかかわらず) 格納される。
162 カーネル 1.3.54 からは 8192、
163 カーネル 2.1.113 からは 16384 になり、
164 カーネル 2.4.23 以降および 2.6 以降ではカーネルのコンパイル時に
166 .\" Under "General setup" ==> "Kernel log buffer size"
167 .\" For 2.6, precisely the option seems to have appeared in 2.5.55.
168 最近のカーネルでは、コマンド 10 でバッファのサイズを問い合わせできる。
171 .\"O .I "syslog(2,buf,len)"
172 .\"O waits until this kernel log buffer is nonempty, and then reads
173 .\"O at most \fIlen\fP bytes into the buffer \fIbuf\fP.
175 .\"O the number of bytes read.
176 .\"O Bytes read from the log disappear from
177 .\"O the log buffer: the information can only be read once.
178 .\"O This is the function executed by the kernel when a user program
180 .\"O .IR /proc/kmsg .
181 .I "syslog(2,buf,len)"
182 の呼び出しはカーネル・ログ・バッファが空でなくなるまで待って、
183 最大 \fIlen\fP バイトまで \fIbuf\fP へと読み出し、読み込んだ
184 バイト数を返す。ログから読まれたバイトはログ・バッファから消える:
188 を読んだ時にカーネルによって実行される関数でもある。
191 .\"O .I syslog(3,buf,len)
192 .\"O will read the last \fIlen\fP bytes from the log buffer (nondestructively),
193 .\"O but will not read more than was written into the buffer since the
194 .\"O last "clear ring buffer" command (which does not clear the buffer at all).
195 .\"O It returns the number of bytes read.
197 の呼び出しはログ・バッファの最後の \fIlen\fP バイトを
198 (非破壊的に)読み出す、しかし、直近の「リング・バッファ消去」命令
199 (この命令はバッファを消去するわけではない)
200 以降にバッファに書き込まれた情報しか読み出せない。
204 .\"O .I syslog(4,buf,len)
205 .\"O does precisely the same, but also executes the "clear ring buffer" command.
207 呼び出しは「リング・バッファ消去」命令も実行する以外は
211 .\"O .I syslog(5,dummy,dummy)
212 .\"O executes just the "clear ring buffer" command.
213 .\"O (In each call where
217 .\"O is shown as "dummy", the value of the argument is ignored by the call.)
218 .I syslog(5,dummy,dummy)
219 呼び出しは「リング・バッファ消去」命令のみを実行する
224 が "dummy" と記載されている場合、その引き数の値が無視されることを表す)。
227 .\"O .I syslog(6,dummy,dummy)
228 .\"O sets the console log level to minimum, so that no messages are printed
230 .I syslog(6,dummy,dummy)
231 呼び出しはコンソールのログレベルを最小に設定し、
232 コンソールにメッセージが表示されないようにする。
235 .\"O .I syslog(7,dummy,dummy)
236 .\"O sets the console log level to default, so that messages are printed
238 .I syslog(7,dummy,dummy)
239 呼び出しはコンソールのログレベルをデフォルトに設定し、
240 コンソールにメッセージが表示されるようにする。
243 .\"O .I syslog(8,dummy,level)
244 .\"O sets the console log level to
246 .\"O which must be an integer between 1 and 8 (inclusive).
249 .\"O section for details.
250 .I syslog(8,dummy,level)
255 は 1 以上 8 以下の整数でなければならない。
261 .\"O .I syslog(9,dummy,dummy)
262 .\"O returns the number of bytes currently available to be read
263 .\"O on the kernel log buffer.
264 .I syslog(9,dummy,dummy)
265 呼び出しはカーネル・ログバッファにある現在読み出し可能なバイト数を返す。
268 .\"O .I syslog(10,dummy,dummy)
269 .\"O returns the total size of the kernel log buffer.
270 .I syslog(10,dummy,dummy)
271 呼び出しはカーネル・ログバッファの総量を返す。
272 .\"O .SS The loglevel
274 .\"O The kernel routine
276 .\"O will only print a message on the
277 .\"O console, if it has a loglevel less than the value of the variable
278 .\"O .IR console_loglevel .
279 .\"O This variable initially has the value
280 .\"O .B DEFAULT_CONSOLE_LOGLEVEL
281 .\"O (7), but is set to 10 if the
282 .\"O kernel command line contains the word "debug", and to 15 in case
283 .\"O of a kernel fault (the 10 and 15 are just silly, and equivalent to 8).
288 変数より小さいときにのみ、コンソールにメッセージを表示する。
291 .B DEFAULT_CONSOLE_LOGLEVEL
292 (7) に設定されるが、起動時にカーネルの
293 コマンド・ライン・オプションに "debug" という単語が含まれている場合は
294 10 に設定され、カーネル・フォールトが発生した場合には 15 に設定される
295 (但し、10 や 15 という数字に意味はなく、8 と同等である)。
296 .\"O This variable is set (to a value in the range 1-8) by the call
297 .\"O .IR syslog(8,dummy,value) .
299 .\"O .I syslog(type,dummy,dummy)
300 .\"O with \fItype\fP equal to 6 or 7, set it to 1 (kernel panics only)
301 .\"O or 7 (all except debugging messages), respectively.
303 .IR syslog(8,dummy,value) .
304 呼び出しによって設定され、値の範囲は 1-8 である。
305 .I syslog(type,dummy,dummy)
306 呼び出しで \fItype\fP が 6 もしくは 7 の場合、
307 console_loglevel は 1 (カーネル・パニックのみ)、
308 7 (デバッグ・メッセージ以外の全て) にそれぞれ設定される。
310 .\"O Every text line in a message has its own loglevel.
312 .\"O .I "DEFAULT_MESSAGE_LOGLEVEL \- 1"
313 .\"O (6) unless the line starts with <d>
314 .\"O where \fId\fP is a digit in the range 1-7, in which case the level
316 .\"O The conventional meaning of the loglevel is defined in
317 .\"O .I <linux/kernel.h>
319 メッセージの各行はそれぞれにログレベルを持つ。このログレベルは
320 .I "DEFAULT_MESSAGE_LOGLEVEL \- 1"
321 (6) であるが、 <d> (\fId\fP は 1-7 の範囲の数字) で始まる行の
328 .\"O #define KERN_EMERG "<0>" /* system is unusable */
329 .\"O #define KERN_ALERT "<1>" /* action must be taken immediately */
330 .\"O #define KERN_CRIT "<2>" /* critical conditions */
331 .\"O #define KERN_ERR "<3>" /* error conditions */
332 .\"O #define KERN_WARNING "<4>" /* warning conditions */
333 .\"O #define KERN_NOTICE "<5>" /* normal but significant condition */
334 .\"O #define KERN_INFO "<6>" /* informational */
335 .\"O #define KERN_DEBUG "<7>" /* debug-level messages */
336 #define KERN_EMERG "<0>" /* システムが使用不能 */
337 #define KERN_ALERT "<1>" /* 直ちに対処が必要 */
338 #define KERN_CRIT "<2>" /* 致命的な状態 */
339 #define KERN_ERR "<3>" /* エラー状態 */
340 #define KERN_WARNING "<4>" /* 警告状態 */
341 #define KERN_NOTICE "<5>" /* 通常状態だが大事な情報 */
342 #define KERN_INFO "<6>" /* 通知 */
343 #define KERN_DEBUG "<7>" /* デバッグレベルの情報 */
345 .\"O .SH "RETURN VALUE"
347 .\"O For \fItype\fP equal to 2, 3, or 4, a successful call to
349 .\"O returns the number
351 .\"O For \fItype\fP 9,
353 .\"O returns the number of bytes currently
354 .\"O available to be read on the kernel log buffer.
355 .\"O For \fItype\fP 10,
357 .\"O returns the total size of the kernel log buffer.
358 .\"O For other values of \fItype\fP, 0 is returned on success.
359 \fItype\fP が 2, 3, 4 の場合、成功すると
363 カーネル・ログバッファにある現在読み出し可能なバイト数を返す。
366 \fItype\fP がそれ以外の値の場合、成功すると 0 が返される。
368 .\"O In case of error, \-1 is returned,
369 .\"O and \fIerrno\fP is set to indicate the error.
371 \fIerrno\fP にエラーを示す値が設定される。
376 .\"O Bad arguments (e.g.,
386 .\"O is less than zero; or for
390 .\"O is outside the range 1 to 8).
404 が 1 以上 8 以下の範囲に入っていない)。
409 .\"O system call is not available, because the kernel was compiled with the
410 .\"O .BR CONFIG_PRINTK
411 .\"O kernel-configuration option disabled.
414 を無効にしてカーネルがコンパイルされているため、
419 .\"O An attempt was made to change console_loglevel or clear the kernel
420 .\"O message ring buffer by a process without sufficient privilege
421 .\"O (more precisely: without the
422 .\"O .B CAP_SYS_ADMIN
426 ケーパビリティを持たないプロセス) が console_loglevelを変更しようとしたか、
427 カーネル・メッセージ・リングを消去しようとした。
430 .\"O System call was interrupted by a signal - nothing was read.
431 .\"O (This can be seen only during a trace.)
432 システム・コールがシグナルによって割り込まれ、何も読み出せなかった。
434 .\"O .SH "CONFORMING TO"
436 .\"O This system call is Linux-specific and should not be used in programs
437 .\"O intended to be portable.
438 このシステム・コールは Linux 特有であり、移植を意図したプログラムでは
442 .\"O From the very start people noted that it is unfortunate that
443 .\"O a system call and a library routine of the same name are entirely
444 .\"O different animals.
445 .\"O In libc4 and libc5 the number of this call was defined by
447 .\"O In glibc 2.0 the syscall is baptized
449 かなり初期の頃から、同じ名前を持つシステム・コールと
450 ライブラリ・ルーチンが全く異なる代物であるのは不幸なことだと
452 libc4 と libc5 ではこのコールの番号は