阅读背景:

用logger 输出printStackTrace()

来源:互联网 
public class HelloLog4jChild extends HelloLog4j {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		logger.debug("This is debug message!");
		logger.info("This is info message!");
		logger.error("This is error message!");
		HelloLog4jChild object = new HelloLog4jChild();
		try {
			object.testMethod();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			//e.printStackTrace();
			logger.error("HelloLog4jException", e);
		}
	}

	public void testMethod() throws Exception {
		try {
			testMethod2();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			// e.printStackTrace();
			throw new ClassNotFoundException("test1 Exception", e);
		}

	}

	public void testMethod2() throws Exception {

		throw new ClassNotFoundException("test2 Exception");
	}

}public class HelloLog4jChild extends HelloLog4j 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: