OSDN Git Service

LDP: Update original to LDP v3.75
[linuxjm/LDP_man-pages.git] / original / man2 / syslog.2
index 5065ca7..d047f9e 100644 (file)
@@ -1,4 +1,6 @@
+'\" t
 .\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
+.\" and Copyright (C) 2012, 2014 Michael Kerrisk <mtk.manpages@gmail.com>
 .\"
 .\" %%%LICENSE_START(VERBATIM)
 .\" Permission is granted to make and distribute verbatim copies of this
@@ -28,7 +30,7 @@
 .\" 2008-02-15, Michael Kerrisk <mtk.manpages@gmail.com>
 .\"     Update LOG_BUF_LEN details; update RETURN VALUE section.
 .\"
-.TH SYSLOG 2  2012-11-29 "Linux" "Linux Programmer's Manual"
+.TH SYSLOG 2  2014-07-08 "Linux" "Linux Programmer's Manual"
 .SH NAME
 syslog, klogctl \- read and/or clear kernel message ring buffer;
 set console_loglevel
@@ -44,32 +46,38 @@ set console_loglevel
 .BI "int klogctl(int " type ", char *" bufp ", int " len );
 .fi
 .SH DESCRIPTION
-If you need the C library function
+.IR Note :
+Probably, you are looking for the C library function
+.BR syslog (),
+which talks to
+.BR syslogd (8);
+see
+.BR syslog (3)
+for details.
+
+This page describes the kernel
 .BR syslog ()
-(which talks to
-.BR syslogd (8)),
-then look at
-.BR syslog (3).
-The system call of this name is about controlling the kernel
+system call, which is used to control the kernel
 .IR printk ()
-buffer, and the glibc wrapper function is called
+buffer; the glibc wrapper function for the system call is called
 .BR klogctl ().
 .SS The kernel log buffer
 The kernel has a cyclic buffer of length
 .B LOG_BUF_LEN
 in which messages given as arguments to the kernel function
 .BR printk ()
-are stored (regardless of their loglevel).
+are stored (regardless of their log level).
 In early kernels,
 .B LOG_BUF_LEN
 had the value 4096;
 from kernel 1.3.54, it was 8192;
-from kernel 2.1.113 it was 16384;
-since 2.4.23/2.6 the value is a kernel configuration option
-.RB ( CONFIG_LOG_BUF_SHIFT ).
+from kernel 2.1.113, it was 16384;
+since kernel 2.4.23/2.6, the value is a kernel configuration option
+.RB ( CONFIG_LOG_BUF_SHIFT ,
+default value dependent on the architecture).
 .\" Under "General setup" ==> "Kernel log buffer size"
 .\" For 2.6, precisely the option seems to have appeared in 2.5.55.
-In recent kernels the size can be queried with command type 10 (see below).
+Since Linux 2.6.6, the size can be queried with command type 10 (see below).
 .SS Commands
 The \fItype\fP argument determines the action taken by this function.
 The list below specifies the values for
@@ -100,7 +108,7 @@ This is the function executed by the kernel when a user program reads
 .TP
 .BR SYSLOG_ACTION_READ_ALL " (3)"
 Read all messages remaining in the ring buffer,
-placing then in the buffer pointed to by
+placing them in the buffer pointed to by
 .IR bufp .
 The call reads the last \fIlen\fP
 bytes from the log buffer (nondestructively),
@@ -134,9 +142,23 @@ and 9
 .RB ( SYSLOG_ACTION_SIZE_UNREAD ).
 .TP
 .BR SYSLOG_ACTION_CONSOLE_OFF " (6)"
-Disable printk to console.
-The call sets the console log level to the minimum,
+The command saves the current value of
+.I console_loglevel
+and then sets
+.I console_loglevel
+to
+.IR minimum_console_loglevel ,
 so that no messages are printed to the console.
+Before Linux 2.6.32,
+.\" commit 1aaad49e856ce41adc07d8ae0c8ef35fc4483245
+the command simply sets
+.I console_loglevel
+to
+.IR minimum_console_loglevel .
+See the discussion of
+.IR /proc/sys/kernel/printk ,
+below.
+
 The
 .I bufp
 and
@@ -144,8 +166,22 @@ and
 arguments are ignored.
 .TP
 .BR SYSLOG_ACTION_CONSOLE_ON " (7)"
-The call sets the console log level to the default,
-so that messages are printed to the console.
+If a previous
+.B SYSLOG_ACTION_CONSOLE_OFF
+command has been performed,
+this command restores
+.I console_loglevel
+to the value that was saved by that command.
+Before Linux 2.6.32,
+.\" commit 1aaad49e856ce41adc07d8ae0c8ef35fc4483245
+this command simply sets
+.I console_loglevel
+to
+.IR default_console_loglevel .
+See the discussion of
+.IR /proc/sys/kernel/printk ,
+below.
+
 The
 .I bufp
 and
@@ -153,11 +189,17 @@ and
 arguments are ignored.
 .TP
 .BR SYSLOG_ACTION_CONSOLE_LEVEL " (8)"
-The call sets the console log level to the value given in
+The call sets
+.I console_loglevel
+to the value given in
 .IR len ,
 which must be an integer between 1 and 8 (inclusive).
+The kernel silently enforces a minimum value of
+.IR minimum_console_loglevel
+for
+.IR len .
 See the
-.B loglevel
+.IR "log level"
 section for details.
 The
 .I bufp
@@ -198,49 +240,84 @@ Since Linux 2.6.37,
 capability (now deprecated for this purpose) or the (new)
 .BR CAP_SYSLOG
 capability.
-.SS The loglevel
-The kernel routine
-.BR printk ()
-will only print a message on the
-console, if it has a loglevel less than the value of the variable
-.IR console_loglevel .
-This variable initially has the value
+.\"
+.\"
+.SS /proc/sys/kernel/printk
+.I /proc/sys/kernel/printk
+is a writable file containing four integer values that influence kernel
+.I printk()
+behavior when printing or logging error messages.
+The four values are:
+.TP
+.I console_loglevel
+Only messages with a log level lower than this value will
+be printed to the console.
+The default value for this field is
 .B DEFAULT_CONSOLE_LOGLEVEL
-(7), but is set to 10 if the
-kernel command line contains the word "debug", and to 15 in case
+(7), but it is set to
+4 if the kernel command line contains the word "quiet", \" since Linux 2.4
+10 if the kernel command line contains the word "debug",
+and to 15 in case
 of a kernel fault (the 10 and 15 are just silly, and equivalent to 8).
-This variable is set (to a value in the range 1-8) by a
+The value of
+.IR console_loglevel
+can be set (to a value in the range 1-8) by a
 .BR syslog ()
 call with a
 .I type
 of 8.
-Calls to
-.BR syslog ()
-with
-.I type
-equal to 6 or 7 set the variable to 1 (kernel panics only)
-or 7 (all except debugging messages), respectively.
+.TP
+.I default_message_loglevel
+This value will be used as the log level for
+.IR printk()
+messages that do not have an explicit level.
+Up to and including Linux 2.6.38,
+the hard-coded default value for this field was 4
+.RB ( KERN_WARNING );
+since Linux 2.6.39,
+.\" commit 5af5bcb8d37f99ba415a1adc6da71051b84f93a5
+the default value is a defined by the kernel configuration option
+.BR CONFIG_DEFAULT_MESSAGE_LOGLEVEL ,
+which defaults to 4.
+.TP
+.I minimum_console_loglevel
+The value in this field is the minimum value to which
+.I console_loglevel
+can be set.
+.TP
+.I default_console_loglevel
+This is the default value for
+.IR console_loglevel .
+.\"
+.\"
+.SS The log level
+Every
+.IR printk ()
+message has its own log level.
+If the log level is not explicitly specified as part of the message,
+it defaults to
+.IR default_message_loglevel .
+The conventional meaning of the log level is as follows:
 
-Every text line in a message has its own loglevel.
-This level is
-.I "DEFAULT_MESSAGE_LOGLEVEL \- 1"
-(6) unless the line starts with <d>
-where \fId\fP is a digit in the range 1-7, in which case the level
-is \fId\fP.
-The conventional meaning of the loglevel is defined in
-.I <linux/kernel.h>
-as follows:
+.TS
+lB lB lB
+lB c l.
+Kernel constant        Level value     Meaning
+KERN_EMERG     0       System is unusable
+KERN_ALERT     1       Action must be taken immediately
+KERN_CRIT      2       Critical conditions
+KERN_ERR       3       Error conditions
+KERN_WARNING   4       Warning conditions
+KERN_NOTICE    5       Normal but significant condition
+KERN_INFO      6       Informational
+KERN_DEBUG     7       Debug-level messages
+.TE
 
-.nf
-#define KERN_EMERG    "<0>"  /* system is unusable               */
-#define KERN_ALERT    "<1>"  /* action must be taken immediately */
-#define KERN_CRIT     "<2>"  /* critical conditions              */
-#define KERN_ERR      "<3>"  /* error conditions                 */
-#define KERN_WARNING  "<4>"  /* warning conditions               */
-#define KERN_NOTICE   "<5>"  /* normal but significant condition */
-#define KERN_INFO     "<6>"  /* informational                    */
-#define KERN_DEBUG    "<7>"  /* debug-level messages             */
-.fi
+The kernel
+.IR printk()
+routine will print a message on the
+console only if it has a log level less than the value of
+.IR console_loglevel .
 .SH RETURN VALUE
 For \fItype\fP equal to 2, 3, or 4, a successful call to
 .BR syslog ()
@@ -284,7 +361,9 @@ system call is not available, because the kernel was compiled with the
 kernel-configuration option disabled.
 .TP
 .B EPERM
-An attempt was made to change console_loglevel or clear the kernel
+An attempt was made to change
+.I console_loglevel
+or clear the kernel
 message ring buffer by a process without sufficient privilege
 (more precisely: without the
 .B CAP_SYS_ADMIN
@@ -299,7 +378,7 @@ System call was interrupted by a signal; nothing was read.
 This system call is Linux-specific and should not be used in programs
 intended to be portable.
 .SH NOTES
-From the very start people noted that it is unfortunate that
+From the very start, people noted that it is unfortunate that
 a system call and a library routine of the same name are entirely
 different animals.
 .\" In libc4 and libc5 the number of this call was defined by
@@ -310,7 +389,7 @@ different animals.
 .BR syslog (3),
 .BR capabilities (7)
 .SH COLOPHON
-This page is part of release 3.68 of the Linux
+This page is part of release 3.75 of the Linux
 .I man-pages
 project.
 A description of the project,