SLF4J、Log4j、Logback三者之间的关系
1.SLF4J、Log4j、Logback三者之间的关系
SLF4J是中日志设计的门面模式,而Log4j和Logback是日志框架的具体实现。
2.Spring项目,自定义日志配置文件加载位置
Web Application
If using Spring in a web application, add the following servlet context listener declaration to web.xml
:
ch.qos.logback.ext.spring.web.LogbackConfigListener
【SLF4J、Log4j、Logback三者之间的关系】This will start up the Logback environment and shut it down in sync with your web application's lifecycle. This listener should be registered before ContextLoaderListener in web.xml, when using custom Logback initialization. For Servlet 2.2 containers and Servlet 2.3 ones that do not initialize listeners before servlets, use LogbackConfigServlet. See the LogbackConfigListener and WebLogbackConfigurer javadoc for details.
If you want to specify the
logback.xml
config file in a location other than the default (root of the classpath), you can specify its location using a Spring resource path with system propertyplaceholders in a logbackConfigLocation
servlet context param in web.xml
:logbackConfigLocation/WEB-INF/logback-${os.name}.xml
3.参考文章 1.slf4j log4j logback关系详解和相关用法
2.【飞天奔月出品】剖析logback4:spring LogbackConfigListener
推荐阅读
- 一个人的碎碎念
- 野营记-第五章|野营记-第五章 讨伐梦魇兽
- Shell-Bash变量与运算符
- 清明,是追思、是传承、是感恩。
- 牛人进化+|牛人进化+ 按自己的意愿过一生
- 七老修复好敏感、角质层薄、红血丝
- 华为旁!大社区、地铁新盘,佳兆业城市广场五期!
- 标签、语法规范、内联框架、超链接、CSS的编写位置、CSS语法、开发工具、块和内联、常用选择器、后代元素选择器、伪类、伪元素。
- 螃蟹和这些食物同吃,轻则腹泻、重则中毒!要小心哦~
- 八、「料理风云」