当前位置:网站首页>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 Server Installation Guide
- GCC compilation
- 智能运维实战:银行业务流程及单笔交易追踪
- 使用htaccess文件禁止目录里的脚本执行权限
- Leetcode skimming: stack and queue 01 (realizing queue with stack)
- Asp .NetCore 微信订阅号自动回复之文本篇
- How to type spaces in latex
- Example explanation: move graph explorer to jupyterlab
- Node -- egg implements the interface of uploading files
- 【CTF】bjdctf_2020_babystack2
猜你喜欢

Talents come from afar, and Wangcheng district has consolidated the intellectual base of "strengthening the provincial capital"

Shell process control

Review data desensitization system

Some understandings of graph convolution neural network r-gcn considering relations and some explanations of DGL official code

时间复杂度与空间复杂度

Niuke - Practice 101 - reasoning clown

Download the online video m3u8 tutorial

GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速

2023款雷克萨斯ES产品公布,这回进步很有感

How do Lenovo computers connect Bluetooth headsets?
随机推荐
Leetcode skimming: stack and queue 05 (inverse Polish expression evaluation)
When installing mysql, there are two packages: Perl (data:: dumper) and Perl (JSON)
Leetcode skimming: binary tree 02 (middle order traversal of binary tree)
Node -- egg implements the interface of uploading files
Kyushu cloud and Intel jointly released the smart campus private cloud framework, enabling new infrastructure for education
Data analysis methodology and previous experience summary [notes dry goods]
An intern's journey to cnosdb
LDR6035智能蓝牙音响可对手机设备持续充放电方案
2023款雷克萨斯ES产品公布,这回进步很有感
Vue force cleaning browser cache
PHP reads ini or env type configuration
Difficult to get up syndrome (bit by bit greed)
What is ThreadLocal memory leak and how to solve it
SQL数据分析之流程控制语句【if,case...when详解】
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
Download the online video m3u8 tutorial
What does open loop and closed loop mean?
ERP项目施行计划的目的是什么?
下载在线视频 m3u8使用教程