Logging uncaught exceptions in Python

How do you cause uncaught exceptions to output via the logging module rather than to stderr? I realize the best way to do this would be: try: raise Exception, ‘Throwing a boring exception’ except Exception, e: logging.exception(e) But my situation is such that it would be really nice if logging.exception(…) were invoked automatically whenever an … Read more

In log4j, does checking isDebugEnabled before logging improve performance?

I am using Log4J in my application for logging. Previously I was using debug call like: Option 1: logger.debug(“some debug text”); but some links suggest that it is better to check isDebugEnabled() first, like: Option 2: boolean debugEnabled = logger.isDebugEnabled(); if (debugEnabled) { logger.debug(“some debug text”); } So my question is “Does option 2 improve … Read more

Python logging: use milliseconds in time format

By default logging.Formatter(‘%(asctime)s’) prints with the following format: 2011-06-09 10:54:40,638 where 638 is the millisecond. I need to change the comma to a dot: 2011-06-09 10:54:40.638 To format the time I can use: logging.Formatter(fmt=”%(asctime)s”,datestr=date_format_str) however the documentation doesn’t specify how to format milliseconds. I’ve found this SO question which talks about microseconds, but a) I … Read more

Spring RestTemplate – how to enable full debugging/logging of requests/responses?

I have been using the Spring RestTemplate for a while and I consistently hit a wall when I’am trying to debug it’s requests and responses. I’m basically looking to see the same things as I see when I use curl with the “verbose” option turned on. For example : curl -v http://twitter.com/statuses/public_timeline.rss Would display both … Read more