异常使用总结
程序员文章站
2022-03-08 16:09:21
...
1、日志的打印基础使用: org.slf4j.Logger
exception不是字符串,不需要 {}
@Test
public void test() {
String string = "test str··";
try {
System.out.println("开始执行代码····");
int i = 1/0;
} catch (Exception e) {
logger.info("info {} Occured exception:", string, e);
logger.info("---------------------------");
logger.warn("warn {} Occured exception:", string, e);
logger.info("---------------------------");
logger.error("error {} Occured exception:", string, e);
}finally {
System.out.println("执行最后代码finally.");
}
}