Why does Python's SysLogHandler require an address?
This code logs to syslog using the syslog module: import syslog syslog.syslog(syslog.LOG_ERR, 'a') And here's the equivalent code using the logging module: import logging from logging.handlers import SysLogHandler logger = logging.getLogger() logger.addHandler(SysLogHandler(address='/dev/log')) logger.setLevel(logging.ERROR) logger.error('a') If I leave out the address parameter in the second snippet, it doesn't do anything. Why does the logging version require me to specify an address, when the syslog module can figure it out on its own? I'd rather not have to specify this path, since it's platform-dependent. Am I going to have to write my own version of SysLogHandler that delegates to the syslog module?
The syslog.syslog API allows you to send events to the system logger on the local machine only, whereas by specifying an address in Python logging you can log not only to the local machine but also a remote syslog server. So, the logging approach covers a wider set of circumstances than syslog.syslog does. Also note that on some platforms / in some environments, syslog.syslog was not always thread-safe (in the past), because the underlying system call API was not thread-safe in those environments. This may not be the case any longer, but it's best to check the documentation for syslog on your platform. For more background, see this Python issue. Also, you can log to a syslog server from Windows machines too, using the logging API (The syslog module is not available on Windows).
From the documentation: Note that if your server is not listening on UDP port 514, SysLogHandler may appear not to work. Have you verified that your syslog is listening to the default port (514) used by SysLogHandler? If they aren't the same, then you will need to provide the specific port number or path to a log to use. See: https://docs.python.org/2/library/logging.handlers.html#sysloghandler
Google Admin SDK insert custom schema using python
Importing images for manifold Isomap
Having nosetests watch files from outside container and rerun tests inside container
Trying to ftp from my system to remote server
Attribute in a Class immediately runs at the wrong time?
Unable to handle “HTTP Badstatus line” exception
How to merge/join two resultset/table in django?
Maximise the Slope using CVXPY
Python-Instagram user_recent_media returning next of none
Django - AttributeError: 'module' object has no attribute 'admin'
Convert pandas (python) categorical x-axis to continuous values when plotting
How to make a specific type of python face tracker
OSError when trying to delete keys from redis
remove/reset matplotlib quiver arrows
Repeating elements in a list
Run python-rq worker process on application start