문제

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