using the sysloghandler class

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nicholas Milkovits

    #1

    using the sysloghandler class

    Hello all,

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

    import logging, logging.handler s

    logger = logging.getLogg er('bender')
    handler = logging.handler s.SysLogHandler (('localhost',
    logging.handler s.SYSLOG_UDP_PO RT),
    logging.handler s.SysLogHandler .LOG_USER)
    formatter = logging.Formatt er('%(filename) s: %(levelname)s: %(message)s')
    handler.setForm atter(formatter )
    logger.addHandl er(handler)
    logger.error('w hat')

    but no log entries show up, however if I use the syslog module as such:
    >>import syslog
    >>syslog.syslog ('testing syslog')
    everything works fine. I am not sure what I am doing wrong. Any help
    would be appreciated.

    Thanks,

    Nick
  • Vinay Sajip

    #2
    Re: using the sysloghandler class

    On Apr 18, 11:42 pm, "Nicholas Milkovits" <nmilkov...@gma il.com>
    wrote:
    Hello all,
    >
    I have a small script which attempts to write to the user.log syslog
    >
    importlogging,l ogging.handlers
    >
    logger =logging.getLog ger('bender')
    handler =logging.handle rs.SysLogHandle r(('localhost', logging.handler s.SYSLOG_UDP_PO RT),logging.han dlers.SysLogHan dler.LOG_USER)
    formatter =logging.Format ter('%(filename )s: %(levelname)s: %(message)s')
    handler.setForm atter(formatter )
    logger.addHandl er(handler)
    logger.error('w hat')
    >
    but no log entries show up, however if I use the syslog module as such:
    >
    >import syslog
    >syslog.syslog( 'testing syslog')
    >
    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

    Comment

    Working...