Change printk print at terminal level

How to change the print level of printk?

(1) view the current print console level

# cat /proc/sys/kernel/printk

 

The file has four digital values, according to their importance logging messages, define where to send it, four data shown above correspond to the following:

The console log level: higher priority than the worthy message will be printed to the console;

The default message log level: This priority will be printed with no priority messages;

The lowest level of the console log: minimum (highest priority) console log level can be set;

The default console log level: default console log level value.

Above the value set, the smaller the value, the higher the priority.

The four values ​​defined above in kernel / printk.c, as follows:

 

The kernel through the printk () information output having log level and log level is controlled by an integer with a string before the angle brackets of the printk () output, for example: printk ( "! <6> Hello World \ n") ;. The kernel provides the 8 different levels of logging, in a corresponding macro definition linux / kernel_levels.h as follows:

 

Thus, printk () can be used as such:

printk(KERN_INFO”Hello World\n”);

When not specified the printk log level () is the default level DEFAULT_MESSAGE_LOGLEVEL, this macro is defined as an integer of 4.

If the information in the kernel boot process you want to print less, may be above kernel / printk.c modify the values ​​according to their needs, recompiled, programming kernel image.

Print Level (2) modify the printk

Modified at the terminal level of the printing system, for example, all kernel printk print mask, then only need to first minimum value of 1 or 0 value can be adjusted

# echo 1       4       1      7 > /proc/sys/kernel/printk
or
# echo 0       4       0      7 > /proc/sys/kernel/printk

Guess you like

Origin www.cnblogs.com/Cqlismy/p/11358446.html