syslog broken on FreeBSD?

Thomas Wouters thomas at xs4all.net
Sun Mar 4 22:51:08 EST 2001


On Sat, Mar 03, 2001 at 03:51:33PM +0100, Gabriel Ambuehl wrote:

> I've been trying to write to syslog using the following
> import syslog
> syslog("TEST)

> but there won't ever appear any message in the syslog. Is this module
> broken on FreeBSD 4.2 or am I doing something very wrong?

You're doing at least two things wrong: after the import, the name 'syslog'
refers to the module object, no the function 'syslog' in the module
'syslog'. And second, you didn't close your string '"TEST"' :)

If you did both those right after all, you might have been looking at the
wrong logfile. If you don't specify a facility using syslog.openlog(),
syslog.syslog() will log using the 'LOG_INFO' priority only. That makes
which logfile it ends it very system specific, because that means the
'facility' is set to 0, and which #define is zero depends on the system. On
FreeBSD, that's 'kernel messages' or the 'kern' syslog facility.

Now you have to search your /etc/syslog.conf for where 'kern.info' messages
are sent. On my FreeBSD systems, that's nowhere. So change your syslog call
to

syslog.syslog(syslog.LOG_ERR, "TEST")

and you'll see something similar to

Mar  5 04:50:14 cvs python: TEST

in your /var/log/messages. 

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list