Linux kernel logs help system administrators fix critical issues by providing information about the state of the system or the daemons that are running. Log levels are used as filters so that any log messages with a lower level and a higher severity are displayed. There are eight log levels based on their severity.
The highest severity level warning. It is used when the system is unstable.
This log level is used when the error requires immediate user attention.
A log level of 2 is used to inform the user of critical software or hardware issues.
Messages pertaining to a log level of 3 are usually used to inform the user of noncritical errors.
The default log level in many Linux distributions. It is used to display warnings about non-important errors.
A log level of 5 is used to represent normal but significant conditions.
KERN_INFO is used to display informational messages.
KERN_DEBUG is used when the system is in debug mode. These messages contain information that is normally only useful when debugging a program.
Checking the log level of your system is a simple and straightforward process. The following command outputs the log level:
$ cat /proc/sys/kernel/printk
This command will output something like this:
4 4 1 7
Here, the first value represents
console_loglevel. This is the current log level used by the system.
The second value represents
default_message_loglevel. When a log level is not specified with a message, this is the value that is used.
The third value represents the
minimum_console_loglevel. This is the minimum log level value that can be used for
console_loglevel, which is usually
The last value is
default_console_loglevel, which is the default value of the log level used at boot.
The log level can be changed using the following command:
$ echo <"loglevel"> | sudo tee /proc/sys/kernel/printk
Or, with root privileges, you can simply run the following command:
echo "3" > /proc/sys/kernel/printk
However, these are temporary ways of changing the log level. When the system restarts, the log will be reset. To change the log level in a persistent way, you have to change the log level from the
GRUB boot loader at boot time.
View all Courses