0

I'm using Python 3.4 on Mac OSX. I have the following code to setup a logger:

LOGGER = logging.getLogger(PROGRAM_NAME) LOGGER.setLevel(logging.DEBUG) LOGGER.propagate = False LOGGER_FH = logging.FileHandler(WORKING_DIR + "/syslog.log", 'a') LOGGER_FH.setLevel(logging.DEBUG) LOGGER_FH.setFormatter(logging.Formatter('%(name)s: [%(levelname)s] %(message)s')) LOGGER.addHandler(LOGGER_FH) LOGGER_SH = logging.handlers.SysLogHandler(address='/var/run/syslog', facility=logging.handlers.SysLogHandler.LOG_USER) LOGGER_SH.setLevel(logging.DEBUG) LOGGER_SH.setFormatter(logging.Formatter('%(name)s: [%(levelname)s] %(message)s')) LOGGER.addHandler(LOGGER_SH) 

The FileHandler works perfectly, and I'm able to see all expected messages at all logging levels show up in the log. The SysLogHandler doesn't work correctly. I'm unable to see any LOGGER.info() or LOGGER.debug() messages in the syslog output. I can see error and warning messages, but not info or debug. Even tweaking the /etc/syslog.conf file has no effect (even after explicitly reloading the syslog daemon with launchctl). What am I missing here ?

2
  • are you sure you have write permissions to that file? Commented Jul 19, 2014 at 22:36
  • @inspectorG4dget To which file are you referring ? The syslog.log file appended to by the FileHandler which I've stated is working just fine, or the /var/run/syslog socket to which some of the messages (but not all) are getting logged by syslog ? Clearly permissions aren't the issue. Commented Jul 19, 2014 at 22:44

1 Answer 1

1

Try: address='/dev/log'

It's a bit confusing from the doc, but "address" is expected to be a unix domain socket, not a file.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.