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?

有帮助吗?

解决方案

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top