默认级别
# cat /proc/sys/kernel/printk
4 4 1 7
分别是:控制台日志级别、默认的消息日志级别、最低的控制台日志级别和默认的控制台日志级别
举例
# echo 0 > /proc/sys/kernel/printk
# cat /proc/sys/kernel/printk
0 4 1 7
在 kernel/printk.c 中定义
int console_printk[4] = {
DEFAULT_CONSOLE_LOGLEVEL, /* console_loglevel */
DEFAULT_MESSAGE_LOGLEVEL, /* default_message_loglevel */
MINIMUM_CONSOLE_LOGLEVEL, /* minimum_console_loglevel */
DEFAULT_CONSOLE_LOGLEVEL, /* default_console_loglevel */
};
8种级别
#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 */
#define KERN_INFO "<6>" /*informational */
#define KERN_DEBUG "<7>" /*debug-level messages */
printk使用
printk(打印级别 "要打印的信息");
syslogd守护进程
/etc/syslog.conf中定义了一些列规则,fedora中的syslogd守护进程叫做rsyslogd,相应它的规则配置文件叫rsyslog.conf。其中有一行”#kern.* /dev/console“它的意思是把所有日志级别的内核log都输出到/dev/console即我们的终端,’#’去掉,重启即可