Arnaud Delobelle wrote:
On 20 February 2012 16:03, Jason Friedman <ja...@powerpull.net> wrote:
I am logging to HTTP:

logger.addHandler(logging.handlers.HTTPHandler(host, url))

Works great, except if my HTTP server happens to be unavailable:

socket.error: [Errno 111] Connection refused

Other than wrapping all my logger.log() calls in try/except blocks, is
there a way to skip logging to the HTTPhandler if the HTTP server is
unavailable?

Here's one: subclass HTTPHandler :)

short answer:

use

> logging.raiseExceptions = 0


long and incomplete answer:

log calls should not raise any exception.

http://docs.python.org/library/logging.html#handler-objects

"Handler.handleError(record)
This method should be called from handlers when an exception is encountered during an emit() call. By default it does nothing, which means that exceptions get silently ignored. This is what is mostly wanted for a logging system - most users will not care about errors in the logging system, they are more interested in application errors. You could, however, replace this with a custom handler if you wish. The specified record is the one which was being processed when the exception occurred"
"

However, I looked into the code and find out an (undocumented ?) attribute of the logging module : raiseException which value is set to 1 by default (python 2.5.2 logging.__version__ < '0.5.0.2' > ).

When set to 1, handlerError print the traceback.

This has been probably fixed in recent version of the module since the handleError doc does not reference raiseException anymore.

JM
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to