using the sysloghandler class

N

Nicholas Milkovits

Hello all,

I have a small script which attempts to write to the user.log syslog

import logging, logging.handlers

logger = logging.getLogger('bender')
handler = logging.handlers.SysLogHandler(('localhost',
logging.handlers.SYSLOG_UDP_PORT),
logging.handlers.SysLogHandler.LOG_USER)
formatter = logging.Formatter('%(filename)s: %(levelname)s: %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.error('what')

but no log entries show up, however if I use the syslog module as such:

everything works fine. I am not sure what I am doing wrong. Any help
would be appreciated.

Thanks,

Nick
 
V

Vinay Sajip

Hello all,

I have a small script which attempts to write to the user.log syslog

importlogging,logging.handlers

logger =logging.getLogger('bender')
handler =logging.handlers.SysLogHandler(('localhost',logging.handlers.SYSLOG_UDP_PORT),logging.handlers.SysLogHandler.LOG_USER)
formatter =logging.Formatter('%(filename)s: %(levelname)s: %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.error('what')

but no log entries show up, however if I use the syslog module as such:


everything works fine. I am not sure what I am doing wrong. Any help
would be appreciated.

The logging package's syslog handler attempts to use UDP to
communicate with the syslog daemon; are you sure your system is set up
with the daemon listening on SYSLOG_UDP_PORT? If it's not, then this
could explain what you are seeing.

Regards,

Vinay Sajip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,843
Latest member
WizcraftEntertainmentAgen

Latest Threads

Top