SysLogHandler is drivin me nuts
Vinay Sajip
vinay_sajip at red-dove.com
Thu Nov 25 09:47:09 EST 2004
michael wrote:
> Hi there,
>
> I am stuck while trying to use the logging facilities. Its not logging
> :-) Can somebody point me to a solution ?
>
> The following snipplets are used
>
> -------------------------------------------
> "crap.py"
>
> logging.config.fileConfig("logging.cfg")
> logger = logging.getLogger ("syslog")
> logger.info('While this is just chatty')
>
> -------------------------------------------
> "logging.cfg"
>
> [syslog]
> class=handlers.SysLogHandler
> level=ERROR
> formatters=form01
> facility=LOG_LOCAL0
> priority = LOG_INFO
>
> [formatters]
> keys=form01
>
> [formatter_form01]
> format=%(levelname)s %(message)s
>
> -------------------------------------------
> "/etc/syslog.conf"
>
> local0.*;local0.!=debug /var/log/local.log
> local0.=debug /var/log/local-d.log
>
The config file appears incomplete - can you post the whole of it (if
it's not too big)? I would have expected to see lines like
[loggers]
keys=root
[handlers]
keys=syslog
[logger_root]
level=DEBUG
qualname=(root)
handlers=syslog
[handler_syslog]
class=handlers.SysLogHandler
level=ERROR
formatter=form01
host=localhost
port=handlers.SYSLOG_UDP_PORT
facility=LOG_LOCAL0
args=(('localhost', handlers.SYSLOG_UDP_PORT),
handlers.SysLogHandler.LOG_LOCAL0)
(the args line may wrap in this mail)
You can't encode the priority in the config file - it is automatically
determined from the logging level (e.g. INFO -> LOG_INFO).
Note that the SysLogHandler communicates with the syslog daemon via UDP
and there may be network problems preventing the messages getting to the
server. If in doubt, format a UDP packet and send directly from a Python
script (i.e. not via logging) to confirm that there is no network problem.
Best regards,
Vinay Sajip
More information about the Python-list
mailing list