当前位置:网站首页>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());
边栏推荐
- Mysql database driver (JDBC Driver) jar package download
- Node——Egg 创建本地文件访问接口
- Use the htaccess file to prohibit the script execution permission in the directory
- 起床困难综合症(按位贪心)
- Window sorting functions rank and deny for SQL data analysis_ rank、raw_ Number and lag, lead window offset function [usage sorting]
- 智能运维实战:银行业务流程及单笔交易追踪
- 记录一下大文件上传偶然成功偶然失败问题
- mysql之B tree 以及 B+tree
- Asp .NetCore 微信订阅号自动回复之文本篇
- Leetcode 96 différents arbres de recherche binaires
猜你喜欢

How do Lenovo computers connect Bluetooth headsets?

Using multithreaded callable to query Oracle Database

时间复杂度与空间复杂度

How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03

4. Object mapping Mapstercover

Leetcode skimming: binary tree 02 (middle order traversal of binary tree)

Windows installation WSL (II)
![Comprehensive usage and case questions of sub query of SQL data analysis [patient sorting]](/img/24/d9a48a0f76cde65421edda04d0f854.png)
Comprehensive usage and case questions of sub query of SQL data analysis [patient sorting]

2023 Lexus ES products have been announced, which makes great progress this time
![Jielizhi, production line assembly link [chapter]](/img/f8/20c41ffe9468d59bf25ea49f73751e.png)
Jielizhi, production line assembly link [chapter]
随机推荐
Shell custom function
Which securities company is safer to open a stock account
The new version of graphic network PDF will be released soon
Leetcode medium question sharing (5)
Linux CentOS7安装Oracle11g的超完美新手教程
UVM tutorial
Accelerator systems initiative is an independent non-profit organization
Comprehensive usage and case questions of sub query of SQL data analysis [patient sorting]
Selectively inhibiting learning bias for active sampling
Is it safe for qiniu college to open an account? How to open an account?
Which app is better and more secure for stock mobile account opening
SQL Server 安装指南
It's nothing to be utilitarian!
Talents come from afar, and Wangcheng district has consolidated the intellectual base of "strengthening the provincial capital"
起床困难综合症(按位贪心)
2022拼多多详情/拼多多商品详情/拼多多sku详情
Leetcode skimming: binary tree 01 (preorder traversal of binary tree)
智能运维实战:银行业务流程及单笔交易追踪
Export default the exported object cannot be deconstructed, and module Differences between exports
@Valid参数校验不生效