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
Psycopg2 Postgre Connection retries
Error for pyspark converting dataframe to rdd
Signal generator specifitc noise modulation
Difference between os.execl() and os.execv() in python
Replace words into special string except nouns and adjectives in Python
Getting private key from ServiceResource create_key_pair
Removing strings from a list that contain dates, without effecting stand alone dates in the list
xliff and placeable substitution
Checking that array doesn't contain negative numbers, and running function again if it does
Matplotlib and non-ascii characters
How does HttpResponse(status=<code>) work in django?
Write a CSV from Urlib and manage encoding properly
python - list index out of range, working with CSV?
Pandas DataFrame get substrings from column
Python GET is not working in browser
Django, Pinax, couldn't extract file