Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing a linux kernel module to report statistics and send some log messages. Can I use syslog to accomplish this job? Or is printk the only way?

share|improve this question

The messages written via printk with the right level end up in syslog anyway (in normal configurations).

However, if you have a really strange setup and you really want to use the user-space syslog from kernel space, you should use the usual suspects (sys_open, sys_write, sys_close) on the /dev/log socket, because this is what syslogd is listening to.

EDIT: By sys_open, sys_open, sys_write, sys_close I meant the system calls implementations of the kernel and not some functions from userspace (syslog.h or whatever).

share|improve this answer
Yes, I tried to use sys_open, sys_write and sys_close from syslog.h. But learnt that one cannot use user level library functions (syslog.h) from kernel modules. So, it looks like printk is my only choice for now unless if I can find a way to hack printk to send messages with different facility other than KERNEL. Thanks for your help tough :) – Obulpathi Sep 16 '11 at 14:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.