更改printk列印級別

2022-07-04 07:33:09 字數 1070 閱讀 3448

1、檢視當前控制台的列印級別

cat /proc/sys/kernel/printk

4    4    1    7

其中第乙個「4」表示核心列印函式printk的列印級別,只有級別比他高的資訊才能在控制台上列印出來,既 0-3級別的資訊

2、修改列印

echo "新的列印級別  4    1    7" >/proc/sys/kernel/printk

echo "4

4 1 7

" > /proc/sys/kernel/printk

3、不夠列印級別的資訊會被寫到日誌中可通過dmesg 命令來檢視

4、printk的列印級別

#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 */

5、printk函式的使用

printk(列印級別  「要列印的資訊」)

列印級別  既上面定義的幾個巨集

更改printk列印級別

1 檢視當前控制台的列印級別 cat proc sys kernel printk 4 4 1 7 其中第乙個 4 表示核心列印函式printk的列印級別,只有級別比他高的資訊才能在控制台上列印出來,既 0 3級別的資訊 2 修改列印 echo 新的列印級別 4 1 7 proc sys kerne...

更改printk列印級別

1 檢視當前控制台的列印級別 cat proc sys kernel printk 4 4 1 7 其中第乙個 4 表示核心列印函式printk的列印級別,只有級別比他高的資訊才能在控制台上列印出來,既 0 3級別的資訊 2 修改列印 echo 新的列印級別 4 1 7 proc sys kerne...

printk列印級別輸出

核心的列印函式和使用者空間的列印函式是相同的,只是關鍵字不太一樣,核心是printk,而使用者空間則是printf。在核心空間只不過有乙個列印級別的設定,所謂的列印級別不過是幾個巨集定義 printk的列印級別一共有8個級別 數字越 明列印級別越高 define kern emerg 0 syste...