Dmesg Notes
Log levels
To set the current log level, run dmesg --console-level loglevel.
For example:
dmesg --console-level debug
Check the log level in /proc/sys/kernel/printk:
# cat /proc/sys/kernel/printk
8 4 1 7
The first number is the one we just set. 8 means debug.
The four numbers mean:
| Number | Description |
|---|---|
| 8 | current console log level |
| 4 | default log level for messages without a specific one |
| 1 | minimum log level |
| 7 | boot-time default log level (used during the initial stages of boot) |
The log levels and their numbers, as shown in /proc/sys/kernel/printk:
| Number | Description |
|---|---|
| 1 | emerg |
| 2 | alert |
| 3 | crit |
| 4 | err |
| 5 | warn |
| 6 | notice |
| 7 | info |
| 8 | debug |
Note: the numbers in /proc/sys/kernel/printk start at 1, while the documentation starts at 0. That can be confusing.
Make it persistent
To keep a console log level across reboots, set it on the kernel command line in GRUB. Edit /etc/default/grub, add loglevel=N to GRUB_CMDLINE_LINUX (or GRUB_CMDLINE_LINUX_DEFAULT), then run sudo update-grub and reboot.
It’s explained well on linuxconfig.org and on kernel.org.