1.SLF4J、Log4j、Logback三者之間的關(guān)系
SLF4J是中日志設(shè)計(jì)的門面模式,而Log4j和Logback是日志框架的具體實(shí)現(xiàn)。
2.Spring項(xiàng)目,自定義日志配置文件加載位置
Web Application
If using Spring in a web application, add the following servlet context listener declaration to web.xml:
<listener>
<listener-class>ch.qos.logback.ext.spring.web.LogbackConfigListener</listener-class>
</listener>
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:
<context-param>
<param-name>logbackConfigLocation</param-name>
<param-value>/WEB-INF/logback-${os.name}.xml</param-value>
</context-param>
3.參考文章
1.slf4j log4j logback關(guān)系詳解和相關(guān)用法
2.【飛天奔月出品】剖析logback4:spring LogbackConfigListener