Making my module's printk's print to my own logfile

273 views Asked by At

I'm doing some Linux module programming. I typically printk little error messages and stuff for debugging - I then exit out of my module and use "dmesg" to see what's up.

That method of debugging is no longer sufficient. I would like to pipe my "printk" text into my own logfile - preferably local, but I understand if that's impossible and I need to put it somewhere like var/log/*.log.

I've looked into editing syslog.conf - but I'm not sure what to do there. I want just my module's printk's in its own files. Is there a simple way to do this that my Google-fu cannot catch?

1

There are 1 answers

1
Ilya Matveychikov On BEST ANSWER

You'll need to start every printk's with the module's unique token:

printk("MyModule: ....", ....);
  1. Use syslog-ng (for example) match rule to catch all the module's output
  2. Use `tail -f /var/log/messages | grep MyModule to see the live kernel's output