简体   繁体   中英

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM