user2228777
user2228777

Reputation: 117

Log4j is not catching exceptions

I am using google app engine and I am having trouble with log4j. Basically I am testing my app and the exceptions are being detected by the dashboard, but not log4j. I am using the following:

 catch (Exception e) {
       logger.warn("Exception Alert", e);
       e.printStackTrace();
   }

Is this the correct way to catch exceptions using Log4j? It works for some exceptions now. But not all. I want to catch a NumberFormatException (empty string) but this is isn't working.

Upvotes: 3

Views: 348

Answers (1)

Roman C
Roman C

Reputation: 1

Yes, it's correct but the logger should be initialized via LogFactory.getLog() and log level should be at least WARN. Also log4j should be on classpath and configured like in this examples.

Upvotes: 1

Related Questions