How to output to syslog before /dev/log exists?

yanegomi at yanegomi at
Mon Dec 31 21:55:23 CET 2012

    Basically I'm trying to write a snippet of code that outputs to both syslog and the console at boot on a FreeBSD box, and I'm not 100% sure how to direct the SysLogHandler to use the dmesg buffer instead of trying to use either localhost:514 (and failing silently), or use /dev/log (and throwing an Exception at boot). Here's an example of what I was trying to use:

import logging
import logging.handlers

# ...

LOG_FORMAT = '<%(name)s> %(message)s'
logger = logging.getLogger('root')
slh = logging.handlers.SysLogHandler(address='/dev/log') # XXX: Does not work if /dev/log doesn't exist -- for obvious reasons.

    Hints within documentation is welcome and appreciated (the terms that needed to be looked for on Google are failing me right now :)..).

More information about the Python-list mailing list