当前位置:网站首页>Slf4j print abnormal stack information
Slf4j print abnormal stack information
2022-07-02 00:33:00 【Zijin xiaofeixia】
SLF4J 1.6.0 The previous version
Only in this way can the error stack be printed
logger.error(String msg, Throwable t);------>logger.error(e.getMessage(),e);
perhaps
logger.info(String msg, Throwable t);------>logger.info(e.getMessage(),e);
@GetMapping("/test")
public String test(){
try {
int i = 1/0;
} catch (Exception e) {
log.error(" Abnormal information ", e);
}
}
therefore SLF4J 1.6.0 The previous version It's usually used String.format Method formatting msg.
SLF4J 1.6.0 After the version ,
error(String format, Object... arguments)
info(String format, Object... arguments)
Normal writing will also print exception stack information , It's just a rule Throwable Object must be the last parameter . If you don't follow this rule , Exception stack information will not be printed .
Be careful e Unwanted {}, If it is added in front, the stack information will not be printed
Write like this :
log.error(" Abnormal information t:{},id:{}.", e.getMessage(),"1234567", e);
You can't write it like that :
log.error(" Abnormal information t:{},id:{}, e:{}", e.getMessage(),"1234567", e);
@GetMapping("/test")
public String test(){
try {
int i = 1/0;
} catch (Exception e) {
log.error(" Abnormal information t:{},id:{}.", e.getMessage(),"1234567", e);
}
return "=========get test success!========";
}
The following methods will not print stack information
log.error(" Abnormal information getStackTrace:{}“, e.getStackTrace());
log.error(” Abnormal information toString:{}", e.toString());
边栏推荐
- SQL数据分析之流程控制语句【if,case...when详解】
- heketi 记录
- leetcode96不同的二叉搜索树
- SQL Server 安装指南
- JS -- image to base code, base to file object
- Correlation - intra group correlation coefficient
- Selectively inhibiting learning bias for active sampling
- The difference between timer and scheduledthreadpoolexecutor
- Jielizhi, production line assembly link [chapter]
- 数据库--SqlServer详解
猜你喜欢
export default 导出的对象,不能解构问题,和module.exports的区别
Leetcode skimming: stack and queue 03 (valid parentheses)
使用 ES 实现疫情地图或者外卖点餐功能(含代码及数据)
Linux CentOS7安装Oracle11g的超完美新手教程
How to improve data quality
ThreadLocal内存泄漏是什么,怎么解决
Flow control statement of SQL data analysis [if, case... When detailed]
Download the online video m3u8 tutorial
2023款雷克萨斯ES产品公布,这回进步很有感
heketi 记录
随机推荐
From 20s to 500ms, I used these three methods
From 20s to 500ms, I used these three methods
It's nothing to be utilitarian!
The difference between timer and scheduledthreadpoolexecutor
Node -- egg creates a local file access interface
Node - generate wechat permission verification configuration
Intelligent operation and maintenance practice: banking business process and single transaction tracking
创业团队如何落地敏捷测试,提升质量效能?丨声网开发者创业讲堂 Vol.03
Leetcode skimming: stack and queue 05 (inverse Polish expression evaluation)
Leetcode 96 différents arbres de recherche binaires
2022拼多多详情/拼多多商品详情/拼多多sku详情
智能运维实战:银行业务流程及单笔交易追踪
实例讲解将Graph Explorer搬上JupyterLab
[CTF] bjdctf 2020 Bar _ Bacystack2
Window sorting functions rank and deny for SQL data analysis_ rank、raw_ Number and lag, lead window offset function [usage sorting]
How to improve data quality
vue 强制清理浏览器缓存
2022 pinduoduo details / pinduoduo product details / pinduoduo SKU details
Guide d'installation du serveur SQL
使用多线程Callable查询oracle数据库