printk的訊息優先權定義在linux/kernel.h

節錄在下面:
1 KERN_EMERG
2 KERN_ALET
3 KERN_CRIT
4 KERN_ERR
5 KERN_WARNIN
6 KERN_NOTICE
7 KERN_INFO
8 KERN_DEBUG

printk 沒有指定時,預設的訊息優先權為 DEFAULT_MESSAGE_LOGLEVEL 為 /proc/sys/kernel/printk 的第二項

log level 數字越低表示印出的訊息越少

printk 會輸出至 cirrular buffer
buffer variable : log_buf
len : LOG_BUF_LEN

/proc/sys/kernel/printk檔案分別定義了
console_loglevel
default_message_loglevel
minimum_console_level
default_console_loglevel

 

The four values in printk denote:
console_loglevel: messages with a higher priority than this will be printed to the console
default_message_loglevel: messages without an explicit priority will be printed with this priority
minimum_console_loglevel: minimum (highest) value to which console_loglevel can be set
default_console_loglevel: default value for console_loglevel

 

printk 的 log level ( Default message loglevel ) 要大於 console_loglevel 這樣一來字才會印出來

Man /proc的定義如下

  1. Messages with a higher priority than console_loglevel will be printed to the console.
  2. Messages without an explicit priority will be printed with priority default_message_level.
  3. Minimum_console_loglevel is the minimum (highest) value to which console_loglevel can be set.
  4. default_console_loglevel is the default value for console_loglevel
    例如: echo "8" > /proc/sys/kernel/printk

LDD 上有說我們只關心前兩項,因此只要2大於1所有printk的訊息就印得出來,因此將1的值調到八,這樣就可印出所有message

arrow
arrow
    全站熱搜

    BB 發表在 痞客邦 留言(0) 人氣()