linux 开启内核日志,linux – 启动时更改默认控制台loglevel

我设置了CentOS 6.3设置,其中控制台loglevel设置为4,默认日志级别设置为4.我知道我可以使用以下步骤更改默认控制台日志级别:

cat /proc/sys/kernel/printk

4 4 1 7

echo 5 > /proc/sys/kernel/printk

cat /proc/sys/kernel/printk

5 4 1 7

但是,重新启动后,控制台日志级别将恢复为原始值.我是否需要重新编译内核,或者有一种方法可以让更改后的值在重新引导时保持持久性.

解决方法:

Do I need to recompile the kernel,

没有.

or is there a way I can get the changed value to be persistent across reboot.

是.

使用内核命令行参数loglevel:

loglevel= All Kernel Messages with a loglevel smaller than the

console loglevel will be printed to the console. It can

also be changed with klogd or other programs. The

loglevels are defined as follows:

0 (KERN_EMERG) system is unusable

1 (KERN_ALERT) action must be taken immediately

2 (KERN_CRIT) critical conditions

3 (KERN_ERR) error conditions

4 (KERN_WARNING) warning conditions

5 (KERN_NOTICE) normal but significant condition

6 (KERN_INFO) informational

7 (KERN_DEBUG) debug-level messages

根据您的引导加载程序(例如Grub或U-Boot),您必须编辑文本以将此新参数添加到命令行.使用cat / proc / cmdline查看用于先前引导的内核命令行.

附录

要显示所有内容,为loglevel参数提供的数字应大于KERN_DEBUG.

也就是说,您必须指定loglevel = 8.

或者只需使用ignore_loglevel参数来显示所有内核消息.

标签:linux,linux-kernel

来源: https://codeday.me/bug/20190928/1828133.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值