SLF 4 J、Log 4 j、Logbackの3つの関係

1440 ワード

1.SLF 4 J、Log 4 j、Logbackの3つの関係
SLF 4 Jは中ログ設計の顔モードであり,Log 4 jと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



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.slf 4 j log 4 j logback関係の詳細と関連用法2.【飞天奔月出品】剖析logback 4:spring LogbackConfigListener