Adding message to assert

You are out of luck here. The best way is to define your own assert macro. Basically, it can look like this: This will define the ASSERT macro only if the no-debug macro NDEBUG isn’t defined. Then you’d use it like this: Which is a bit simpler than your usage since you don’t need to … Read more

What is the significance of log4j.rootLogger property in log4j.properties file? What happens if I don’t use this property?

Samudra Gupta explains in his book1: The Logger object is the main object that an application developer uses to log any message. The Logger objects acting within a particular instance of an application follow a parent-child hierarchy. If you have the following configuration: This is how the logger hierarchy could end up looking:2 Samudra Gupta continues to explain: At the … Read more

python exception message capturing

You have to define which type of exception you want to catch. So write except Exception, e: instead of except, e: for a general exception (that will be logged anyway). Other possibility is to write your whole try/except code this way: in Python 3.x and modern versions of Python 2.x use except Exception as e instead of except Exception, e: