protect logger from shutdown syslogd

Discussion in 'Python' started by Mathias KÅ‘rber, Feb 25, 2013.

  1. Hi

    I have a script which calls getLogger to set up a logging service.
    The standard logger description used both the consoleHandler and the
    syslogHandler.

    It seems that if syslogd is shut down, getLogger fails, and the script
    won't be able to log at all.

    is there a way to make it immune against this and automatically continue
    the consoleHandler. Sure, we could amend the .ini file
    to remove the syslogHandler from the logger definition when this is
    known, but on a cron-initiated script this is not feasible.

    below is the logger definition:

    > [loggers]
    > keys=root,mylogger
    >
    > [handlers]
    > keys=consoleHandler,syslogHandler,rootHandler
    >
    > [formatters]
    > keys=simpleFormatter,syslogFormatter,rootFormatter
    >
    > [logger_root]
    > level=NOTSET
    > handlers=rootHandler
    >
    > [logger_mylogger]
    > level=INFO
    > handlers=consoleHandler,syslogHandler
    > #handlers=syslogHandler
    > #handlers=consoleHandler
    > qualname=mylogger
    > propagate=0
    >
    > [handler_rootHandler]
    > class=StreamHandler
    > level=DEBUG
    > formatter=rootFormatter
    > args=(sys.stdout,)
    >
    > [handler_consoleHandler]
    > class=StreamHandler
    > level=DEBUG
    > formatter=simpleFormatter
    > args=(sys.stdout,)
    >
    > [handler_syslogHandler]
    > class=handlers.SysLogHandler
    > formatter=syslogFormatter
    > level=INFO
    > #args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)
    > args=('/dev/log', handlers.SysLogHandler.LOG_USER)



    thanks
    Mathias KÅ‘rber, Feb 25, 2013
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sachin
    Replies:
    1
    Views:
    962
    Soren Kuula
    Feb 3, 2006
  2. Dan Stromberg

    syslogd?

    Dan Stromberg, Jul 9, 2003, in forum: Python
    Replies:
    1
    Views:
    501
    Sami Juvonen
    Jul 10, 2003
  3. Ara.T.Howard

    syslogging to remote syslogd

    Ara.T.Howard, Nov 2, 2004, in forum: Ruby
    Replies:
    2
    Views:
    99
  4. cap
    Replies:
    3
    Views:
    282
    James Edward Gray II
    Dec 11, 2005
  5. Georges Ko
    Replies:
    4
    Views:
    266
    Georges Ko
    Jul 26, 2006
Loading...

Share This Page