如何控制内核打印级别
2013-05-14 11:00
309 查看
printk and console log level.
printk is used in kernel programming to print messages into the kernel logs.
The syntax of printk is
printk ("log level" "message", <arguments>);
The log levels decide the importance of the message being printed, kernel defines 8 log levels in the file printk.h
#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*/
We can see each log level corresponds to a number and the lower the number higher the importance of the message.
The levels are useful in deciding what should be displayed to the user on the console and what should not be.
Every console has log level called as the the console log level and any message with a log level number lesser than the console log level gets displayed on the console, and other messages which have a log level number higher or equal to the console log level
are logged in the kernel log which can be looked into using the command "dmesg".
The console loglevel can be found by looking into the file /proc/sys/kernel/printk
$ cat /proc/sys/kernel/printk
4 4 1 7
The first number in the output is the console log level, the second is the default log level, third is the minimum log level and fourth is the maximum log level.
Log level 4 corresponds to KERN_WARNING. Thus all the messages with log levels 3,2,1 and 0 will get displayed on the screen as well as logged and the messages with log level 4,5,6,7 only get logged and can be viewed using "dmesg".
The console log level can be changed by writing into the proc entry
$ echo "6" > /proc/sys/kernel/printk
$ cat /proc/sys/kernel/printk
6 4 1 7
Now the console log level is set to 6, which is KERN_INFO.
可以用dmesg -n level 设定printk输出级别。
printk is used in kernel programming to print messages into the kernel logs.
The syntax of printk is
printk ("log level" "message", <arguments>);
The log levels decide the importance of the message being printed, kernel defines 8 log levels in the file printk.h
#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*/
We can see each log level corresponds to a number and the lower the number higher the importance of the message.
The levels are useful in deciding what should be displayed to the user on the console and what should not be.
Every console has log level called as the the console log level and any message with a log level number lesser than the console log level gets displayed on the console, and other messages which have a log level number higher or equal to the console log level
are logged in the kernel log which can be looked into using the command "dmesg".
The console loglevel can be found by looking into the file /proc/sys/kernel/printk
$ cat /proc/sys/kernel/printk
4 4 1 7
The first number in the output is the console log level, the second is the default log level, third is the minimum log level and fourth is the maximum log level.
Log level 4 corresponds to KERN_WARNING. Thus all the messages with log levels 3,2,1 and 0 will get displayed on the screen as well as logged and the messages with log level 4,5,6,7 only get logged and can be viewed using "dmesg".
The console log level can be changed by writing into the proc entry
$ echo "6" > /proc/sys/kernel/printk
$ cat /proc/sys/kernel/printk
6 4 1 7
Now the console log level is set to 6, which is KERN_INFO.
可以用dmesg -n level 设定printk输出级别。
相关文章推荐
- 如何将linux内核的带级别控制的printk内容打印出来
- 如何修改内核打印级别
- 不使用流程控制语言,如何打印出1~1000的整数?
- 如何进行打印次数控制
- 如何灵活控制log4j日志输出级别
- 要将linux内核的带级别控制的printk内容打印出来,在命令行 输入 dmesg -n 8 就将所有级别的信息都打印出来
- 如何打印整个 VB 窗体和控制打印大小
- 调整内核printk的打印级别
- windows下如何用python控制打印机打印
- (转)log4j(三)——如何控制不同级别的日志信息的输出?
- 如何通过JS控制父级别框架可是高度
- 手动调整内核printk打印级别
- log4j(三)——如何控制不同级别的日志信息的输出?
- 如何控制Linux中的运行级别
- SAP MM 用户不希望采购订单一旦Release就自动打印输出,如何控制?
- 如何通过配置log4j.xml来打印指定类或指定级别的日志信息
- 如何通过配置log4j.xml来打印指定类或指定级别的日志信息
- SAP中如何控制某个report一次只能打印一份
- 内核级研究-arm926ejs内核如何控制TCM、Cache、MMU等
- Linux dmesg --查看开机信息/打印或控制内核环形缓冲区