syslog(2) System Calls Manual syslog(2) syslog, klogctl - / ; console_loglevel LIBRARY Standard C library (libc, -lc) #include /* SYSLOG_* */ #include /* SYS_* */ #include int syscall(SYS_syslog, int type, char *bufp, int len); /* glibc */ #include int klogctl(int type, char *bufp, int len); : , syslog(), syslogd(8); syslog(3). syslog(), printk() ; glibc klogctl(). The kernel has a cyclic buffer of length LOG_BUF_LEN in which messages given as arguments to the kernel function printk() are stored (regardless of their log level). In early kernels, LOG_BUF_LEN had the value 4096; from Linux 1.3.54, it was 8192; from Linux 2.1.113, it was 16384; since Linux 2.4.23/2.6, the value is a kernel configuration option (CONFIG_LOG_BUF_SHIFT, default value dependent on the architecture). Since Linux 2.6.6, the size can be queried with command type 10 (see below). type . type. , ; , . SYSLOG_ACTION_CLOSE (0) . . SYSLOG_ACTION_OPEN (1) . . SYSLOG_ACTION_READ (2) . - len , bufp. . , , : . /proc/kmsg. SYSLOG_ACTION_READ_ALL (3) , , , bufp. len ( ), , << >> ( 5 ). . SYSLOG_ACTION_READ_CLEAR (4) , . , type 3, << >>. SYSLOG_ACTION_CLEAR (5) << >>. bufp len . . , , 3 (SYSLOG_ACTION_READ_ALL) 4 (SYSLOG_ACTION_READ_CLEAR). 2 (SYSLOG_ACTION_READ) 9 (SYSLOG_ACTION_SIZE_UNREAD). SYSLOG_ACTION_CONSOLE_OFF (6) console_loglevel console_loglevel minimum_console_loglevel, . Linux 2.6.32, console_loglevel minimum_console_loglevel. /proc/sys/kernel/printk . bufp len . SYSLOG_ACTION_CONSOLE_ON (7) SYSLOG_ACTION_CONSOLE_OFF, console_loglevel, . Linux 2.6.32 console_loglevel default_console_loglevel. /proc/sys/kernel/printk . bufp len . SYSLOG_ACTION_CONSOLE_LEVEL (8) console_loglevel , len, 1 8 (). minimum_console_loglevel len. . bufp . SYSLOG_ACTION_SIZE_UNREAD (9) ( Linux 2.4.10) , 2 (SYSLOG_ACTION_READ). bufp len . SYSLOG_ACTION_SIZE_BUFFER (10) ( Linux 2.6.6) . bufp len . All commands except 3 and 10 require privilege. In Linux kernels before Linux 2.6.37, command types 3 and 10 are allowed to unprivileged processes; since Linux 2.6.37, these commands are allowed to unprivileged processes only if /proc/sys/kernel/dmesg_restrict has the value 0. Before Linux 2.6.37, "privileged" means that the caller has the CAP_SYS_ADMIN capability. Since Linux 2.6.37, "privileged" means that the caller has either the CAP_SYS_ADMIN capability (now deprecated for this purpose) or the (new) CAP_SYSLOG capability. /proc/sys/kernel/printk /proc/sys/kernel/printk 4 , printk() . : 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 DEFAULT_CONSOLE_LOGLEVEL (7), but it is set to 4 if the kernel command line contains the word "quiet", 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). The value of console_loglevel can be set (to a value in the range 1-8) by a syslog() call with a type of 8. default_message_loglevel printk(), . Linux 2.6.38 4 (KERN_WARNING); Linux 2.6.39, CONFIG_DEFAULT_MESSAGE_LOGLEVEL 4. minimum_console_loglevel -- , console_loglevel. default_console_loglevel console_loglevel. printk() . , default_message_loglevel. : KERN_EMERG 0 KERN_ALERT 1 KERN_CRIT 2 KERN_ERR 3 KERN_WARNING 4 KERN_NOTICE 5 , KERN_INFO 6 KERN_DEBUG 7 C printk() , console_loglevel. type 2, 3 4, syslog() . type 9, syslog() , . type 10, syslog() . type 0. -1, errno . EINVAL (, type; type 2, 3, 4, buf NULL len ; type 8, level 1 8). ENOSYS syslog() , CONFIG_PRINTK. EPERM , ( CAP_SYS_ADMIN CAP_SYSLOG), console_loglevel . ERESTARTSYS ; ( ). Linux. , . . dmesg(1), syslog(3), capabilities(7) Alexander Golubev , Azamat Hackimov , Hotellook, Nikita , Spiros Georgaras , Vladislav , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . syslog(2)