当前位置:网站首页>Logback logger and root
Logback logger and root
2022-04-23 14:12:00 【All the names I thought of were used】
One 、root and logger
<logger> Used to set the log printing level of a package or a specific class 、 And the designation appender. It can contain zero or more <appender-ref> Elements , Identify this appender Will be added to this logger.
<root> It's also <logger> Elements , But it's a root logger, only one level attribute , Because of its name Namely ROOT
Next, let's talk about logger and root Use
scene
logback To configure
<logger name="com.codexie.controller.demo1" level="debug">
<appender-ref ref="Stdout" />
<appender-ref ref="RollingFile" />
</logger>
<logger name="com.codexie.controller.demo2" level="warn"></logger>
<!-- Log output level -->
<root level="info">
<appender-ref ref="Stdout" />
<appender-ref ref="RollingFile" />
</root>
We can see demo1 Of level Set to debug,demo2 Of level by warn, and root Of level by info
controller
@Controller
public class demo1 {
private static final Logger logger = LoggerFactory.getLogger(demo1.class);
@RequestMapping("demo1")
@ResponseBody
public String logBack(){
logger.debug("demo1:logback debug");
logger.info("demo1:logback info");
return "ok";
}
}
@Controller
public class demo2 {
private static final Logger logger = LoggerFactory.getLogger(demo2.class);
@RequestMapping("demo2")
@ResponseBody
public String logBack(){
logger.info("demo2:logback run");
logger.debug("demo2:logback info");
logger.warn("demo2:logback warn");
return "ok";
}
}
visit demo1

You can see that the same message has been printed twice , because demo1 Of level yes debug, therefore debug and info All levels of information can · Print , Again because logger and root There are appender, So the same message is printed twice .
visit demo2

visit demo2 Only one message was printed , because demo2 Of level by warn, So it won't print debug and info Level information , Only print warn Level information , Again because demo2 Of logger No configuration appender, So use root Of appender Print once .
Scenario two
<logger name="com.codexie.controller.demo1" level="debug"> </logger>
<logger name="com.codexie.controller.demo2" level="warn"></logger>
<!-- Log output level -->
<root level="info">
<appender-ref ref="Stdout" />
<appender-ref ref="RollingFile" />
</root>
We will demo1 Of appender And cancelled , Verify to see if demo1 The log information of is only printed once

Verify success , The conclusion is correct
版权声明
本文为[All the names I thought of were used]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231404419674.html
边栏推荐
- Subscription number development of wechat applet (message push)
- Cdh6 based on CM management 3.2 cluster integration atlas 2 one
- MySQL数据库讲解(九)
- 星界边境文本自动翻译机使用说明
- 更改plsql工具栏的图标大小
- Promtail + Loki + Grafana 日志监控系统搭建
- Recyclerview advanced use (II) - simple implementation of vertical drag and drop sorting
- 按实际取,每三级分类汇总一次,看图知需求
- HyperBDR云容灾V3.2.1版本发布|支持更多云平台,新增监控告警功能
- HyperMotion云迁移助力中国联通,青云完成某央企上云项目,加速该集团核心业务系统上云进程
猜你喜欢

win10自带Groove音乐不能播放CUE和APE文件的一种曲线救国办法,自己创建aimppack插件包,AIMP安装DSP插件

Win10 comes with groove music, which can't play cue and ape files. It's a curvilinear way to save the country. It creates its own aimpack plug-in package, and aimp installs DSP plug-in

Cdh6 based on CM management 3.2 cluster integration atlas 2 one

Intégration de Clusters CDH Phoenix basée sur la gestion cm

Wechat applet obtains login user information, openid and access_ token

MySQL数据库讲解(九)

Visio installation error 1:1935 2: {XXXXXXXX

Jmeter安装教程以及我遇到的问题的解决办法

帆软分割求解:一段字符串,只取其中某个字符(所需要的字段)
poi操作word模板替换数据并且导出word
随机推荐
关于Jmeter启动闪退问题
On the multi-level certificate based on OpenSSL, the issuance and management of multi-level Ca, and two-way authentication
Indoor and outdoor map switching (indoor three-point positioning based on ibeacons)
How QT designer adds resource files
RobotFramework 之 公共变量
云迁移的六大场景
基于ibeacons签到系统
教育行业云迁移最佳实践:海云捷迅使用HyperMotion云迁移产品为北京某大学实施渐进式迁移,成功率100%
什么是云迁移?云迁移的四种模式分别是?
如何快速批量创建文本文档?
室内外地图切换(室内基于ibeacons三点定位)
关于密匙传递的安全性和数字签名
RobotFramework 之 项目框架
HyperMotion云迁移完成阿里云专有云产品生态集成认证
MySQL数据库讲解(八)
快速安装mongodb
jsp学习3
1到100号的灯开关问题
Recyclerview advanced use (II) - simple implementation of vertical drag and drop sorting
查询2013年到2021年的数据,只查询到2020的数据,遇到了这个问题所进行的解决办法