Siva Kannan
Siva Kannan

Reputation: 2481

difference between console log level and default log lovel

in module programming i read ,

if log level is

  less than console log level will get displayed and 
  higher than will be mentioned in log files , 

if i dont specify any log level in printk statement then the default log level will be taken .

i just saw the default and console log level

by

cat /proc/sys/kernel/printk

and the result was

4 4 1 7

here both default and console was same .

i dont understand why default log level created . are we going to use the default log level in anywhere .

what is the exact difference between console log level and default log level .

i am new to module programming.

Upvotes: 0

Views: 2352

Answers (1)

kzs
kzs

Reputation: 1875

As we know we have different kernel level logs:

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

Okay let us put for discussion separately:

Console log level is something which is used to set log levels that can be displayed on console window with Log levels(printk) < Console log level(4 taken considering wrt your case).

i.e., it will print kernel messages with printk using log levels from 0,1,2 and 3. rest 4 to 7 will be logged in circular buffer maintained by kernel - can be seen issuing "dmesg".

Now if we move on to Default log level:

Whenever you use printk without any log level info, say for eg:

printk("Insmod my first driver\n"); // this log level will be set to "kern_warning"(as default log level is 4).

So the difference is console log is used to decide what is needed to be printed on console and default log level is used for what log level is to be taken by default if not mentioned by printk during kernel module programming.

Upvotes: 1

Related Questions