Log4j2完全讲解

来源:互联网 发布:俄语翻译软件下载 编辑:程序博客网 时间:2024/05/24 06:34

 本文内容大多翻译自log4j官网。

    Apache的开源项目log4j(log for java)是一个功能强大的日志组件,提供方便的日志记录。在apache网站:http://www.apache.org/dyn/closer.cgi/logging/log4j 可以免费下载到Log4j最新版本的软件包。

    但是,后来Apache软件基金会发布了Log4j 2.0通用版本,相比之前Log4j的1.x版本有了很大的性能提升。本版本的灵感来自于诸如Log4j 1.x和java.util.logging之类的已有日志解决方案,它是经过了数年的努力从头开始编写完成的。 Log4j 2.0引入了新的插件系统、对properties的支持、对基于 JSON配置的支持和配置的自动化重载。它支持很多已有的日志框架,包括SLF4J、Commons Logging、Apache Flum、Log4j 1.x,并提供了新的程序员API。

    截止发帖时间Log4j2最新版本是 2015.12.10 5:00发布的2.5版本。

1、认识log4j2

    日志是应用软件中不可缺少的部分,服务器后期的维护,日志是最重要的一个依据。

    Apache log4j(log for java)是 Apache 软件基金会项目和由提交者的 Apache 软件基金会专门团队开发。

    Apache Log4j2是 Log4j 1.x的重构,提供的许多改进可用在 Logback,同时修复Logback的体系结构中的一些固有的问题。

    1.2、Log4j 2中的改进

      1.2.1、API 分离

    Log4j的API是独立于实现明确的类和方法,应用程序开发人员可以使用同时确保向前兼容性。

      1.2.2、更好的性能

    Log4j2基于LMAX Disruptor library的下一代异步记录器。在多线程方案中异步记录器相比Log4j 1.x和Logback有18倍的日志记录效率和更低的延迟。详细信息,请参阅性能。

      1.2.3、更加先进的Api支持

    Log4j 2 API提供了最佳的性能,但同时,Log4j2提供了对SLF4J和Commons Logging APIs的支持。

    在这之前,程序员们以如下方式进行日志记录:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">if</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">logger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">isDebugEnabled</span><span class="pun" style="color: rgb(102, 102, 0);">())</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">{</span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">logger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">debug</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"Hi, "</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">+</span><span class="pln" style="color: rgb(0, 0, 0);"> u</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">getA</span><span class="pun" style="color: rgb(102, 102, 0);">()</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">+</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">“</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">“</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">+</span><span class="pln" style="color: rgb(0, 0, 0);"> u</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">getB</span><span class="pun" style="color: rgb(102, 102, 0);">());</span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);">}</span></li></ol>

    许多人都会抱怨上述代码的可读性太差了。如果有人忘记写if语句,程序输出中会多出很多不必要的字符串。log4j 2.0开发团队鉴于以上考虑对API进行了完善。现在你可以这样写代码:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">logger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">debug</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"Hi, {} {}"</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> u</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">getA</span><span class="pun" style="color: rgb(102, 102, 0);">(),</span><span class="pln" style="color: rgb(0, 0, 0);"> u</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">getB</span><span class="pun" style="color: rgb(102, 102, 0);">());</span></li></ol>

    和其它一些流行的日志框架一样, 新的API也支持变量参数的占位符功能。 log4j 2.0还支持其它一些很棒的功能,像Markers和flow tracing:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">private</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">Logger</span><span class="pln" style="color: rgb(0, 0, 0);"> logger </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">LogManager</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">getLogger</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="typ" style="color: rgb(102, 0, 102);">MyApp</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="kwd" style="color: rgb(0, 0, 136);">class</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">getName</span><span class="pun" style="color: rgb(102, 102, 0);">());</span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">private</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">static</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">final</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">Marker</span><span class="pln" style="color: rgb(0, 0, 0);"> QUERY_MARKER </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">MarkerManager</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">getMarker</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"SQL"</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);">...</span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">public</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">String</span><span class="pln" style="color: rgb(0, 0, 0);"> doQuery</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="typ" style="color: rgb(102, 0, 102);">String</span><span class="pln" style="color: rgb(0, 0, 0);"> table</span><span class="pun" style="color: rgb(102, 102, 0);">)</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">{</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">logger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">entry</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">param</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">logger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">debug</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">QUERY_MARKER</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="str" style="color: rgb(0, 136, 0);">"SELECT * FROM {}"</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> table</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">return</span><span class="pln" style="color: rgb(0, 0, 0);"> logger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="kwd" style="color: rgb(0, 0, 136);">exit</span><span class="pun" style="color: rgb(102, 102, 0);">();</span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);">}</span></li></ol>

    Markers可以帮助你很快地找到具体的日志项(Log Entries)。而在某个方法的开头和结尾调用Flow Traces中的一些方法,你可以在日志文件中看到很多新的跟踪层次的日志项,也就是说,你的程序工作流(Program Flow)被记录下来了。下面是Flow Traces的一些例子:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="lit" style="color: rgb(0, 102, 102);">19</span><span class="pun" style="color: rgb(102, 102, 0);">:</span><span class="lit" style="color: rgb(0, 102, 102);">08</span><span class="pun" style="color: rgb(102, 102, 0);">:</span><span class="lit" style="color: rgb(0, 102, 102);">07.056</span><span class="pln" style="color: rgb(0, 0, 0);"> TRACE com</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">test</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="typ" style="color: rgb(102, 0, 102);">TestService</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">19</span><span class="pln" style="color: rgb(0, 0, 0);"> retrieveMessage </span><span class="pun" style="color: rgb(102, 102, 0);">-</span><span class="pln" style="color: rgb(0, 0, 0);"> entry</span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="lit" style="color: rgb(0, 102, 102);">19</span><span class="pun" style="color: rgb(102, 102, 0);">:</span><span class="lit" style="color: rgb(0, 102, 102);">08</span><span class="pun" style="color: rgb(102, 102, 0);">:</span><span class="lit" style="color: rgb(0, 102, 102);">07.060</span><span class="pln" style="color: rgb(0, 0, 0);"> TRACE com</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">test</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="typ" style="color: rgb(102, 0, 102);">TestService</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">46</span><span class="pln" style="color: rgb(0, 0, 0);"> getKey </span><span class="pun" style="color: rgb(102, 102, 0);">-</span><span class="pln" style="color: rgb(0, 0, 0);"> entry</span></li></ol>
      1.2.4、配置自动重新加载

    自动重新加载配置文件:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);"><?</span><span class="pln" style="color: rgb(0, 0, 0);">xml version</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"1.0"</span><span class="pln" style="color: rgb(0, 0, 0);"> encoding</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"UTF-8"</span><span class="pun" style="color: rgb(102, 102, 0);">?></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"><configuration</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">monitorInterval</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"30"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">...</span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"></configuration></span></li></ol>

    监控的时间间隔单位为秒,最小值是5。这意味着,log4j 2在配置改变的情况下可以重新配置日志记录行为。如果值设置为0或负数,log4j 2不会对配置变更进行监测。最为称道的一点是:不像其它日志框架, log4j 2.0在重新配置的时候不会丢失之前的日志记录

    本次使用的基本工程是Spring4 MVC + Hibernate5 为基础工程,然后集成log4j2。

    log4j2最好的教程在 这里 。

      1.2.5、插件式的架构

    log4j 2.0支持插件式的架构。你可以根据需要自行扩展log4j 2.0,这非常简单。首先,你要为你的扩展建立好命名空间,然后告诉log4j 2.0在哪能够找到它:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"><configuration</span><span class="pln" style="color: rgb(0, 0, 0);"> … </span><span class="atn" style="color: rgb(102, 0, 102);">packages</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"de.grobmeier.examples.log4j2.plugins"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li></ol>

    根据上述配置,log4j 2将会在de.grobmeier.examples.log4j2.plugins包中找寻你的扩展插件。如果你建立了多个命名空间,没关系,用逗号分隔就可以了。 下面是一个简单的扩展插件:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="lit" style="color: rgb(0, 102, 102);">@Plugin</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">name </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="str" style="color: rgb(0, 136, 0);">"Sandbox"</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> type </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="str" style="color: rgb(0, 136, 0);">"Core"</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> elementType </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="str" style="color: rgb(0, 136, 0);">"appender"</span><span class="pun" style="color: rgb(102, 102, 0);">)</span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">public</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">class</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">SandboxAppender</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">extends</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">AppenderBase</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">{</span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">private</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">SandboxAppender</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="typ" style="color: rgb(102, 0, 102);">String</span><span class="pln" style="color: rgb(0, 0, 0);"> name</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">Filter</span><span class="pln" style="color: rgb(0, 0, 0);"> filter</span><span class="pun" style="color: rgb(102, 102, 0);">)</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">{</span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">super</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">name</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> filter</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">null</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">public</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">void</span><span class="pln" style="color: rgb(0, 0, 0);"> append</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="typ" style="color: rgb(102, 0, 102);">LogEvent</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">event</span><span class="pun" style="color: rgb(102, 102, 0);">)</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">{</span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">System</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="kwd" style="color: rgb(0, 0, 136);">out</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">println</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="kwd" style="color: rgb(0, 0, 136);">event</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">getMessage</span><span class="pun" style="color: rgb(102, 102, 0);">().</span><span class="pln" style="color: rgb(0, 0, 0);">getFormattedMessage</span><span class="pun" style="color: rgb(102, 102, 0);">());</span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">@PluginFactory</span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">public</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">static</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">SandboxAppender</span><span class="pln" style="color: rgb(0, 0, 0);"> createAppender</span><span class="pun" style="color: rgb(102, 102, 0);">(</span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">@PluginAttr</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"name"</span><span class="pun" style="color: rgb(102, 102, 0);">)</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">String</span><span class="pln" style="color: rgb(0, 0, 0);"> name</span><span class="pun" style="color: rgb(102, 102, 0);">,</span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">@PluginElement</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"filters"</span><span class="pun" style="color: rgb(102, 102, 0);">)</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">Filter</span><span class="pln" style="color: rgb(0, 0, 0);"> filter</span><span class="pun" style="color: rgb(102, 102, 0);">)</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">{</span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">return</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">new</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">SandboxAppender</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">name</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> filter</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);">}</span></li></ol>

    上面标有@PluginFactory注解的方法是一个工厂,它的两个参数直接从配置文件读取。用@PluginAttr和@PluginElement进行了实现。剩下的就非常简单了。由于写的是一个Appender,因此得继承AppenderBase这个类。该类必须实现append()方法,从而进行实际的逻辑处理。除了Appender,你甚至可以实现自己的Logger和Filter。可以参看官方文档。

2、log4j2更多介绍

    2.1、基本配置介绍

    classes

    Logger间的层次关系

    相比于纯粹的System.out.println方式,使用logging API的最首要以及最重要的优势是可以在禁用一些log语句块的同时允许其他的语句块的输出。这一能力建立在一种假设之上,即所有在应用中可能出现的logging语句可以按照开发者定义的标准分成不同的类型。 在 Log4j 1.x版本时,Logger的层次是靠Logger类之间的关系来维护的。

    但在Log4j2中, Logger的层次则是靠LoggerConfig对象之间的关系来维护的。 Logger和LoggerConfig均是有名称的实体。Logger的命名是大小写敏感的,并且服从如下的分层命名规则。(与java包的层级关系类似)。例如:com.foo是com.foo.Bar的父级;java是java.util的父级,是java.util.vector的祖先。

    root LoggerConfig位于LoggerConfig层级关系的最顶层。它将永远存在与任何LoggerConfig层次中。

    任何一个希望与root LoggerConfig相关联的Logger可以通过如下方式获得: Logger logger = LogManager.getLogger(LogManager.ROOT_LOGGER_NAME);

    其他的Logger实例可以调用LogManager.getLogger 静态方法并传入想要得到的Logger的名称来获得。

    Configuration

    Configuration包含了所有的Appenders、上下文范围内的过滤器、LoggerConfigs以及StrSubstitutor.的引用。在重配置期间,新与旧的Configuration将同时存在。当所有的Logger对象都被重定向到新的Configuration对象后,旧的Configuration对象将被停用和丢弃。

    Logger

    Loggers 是通过调用LogManager.getLogger方法获得的。Logger对象本身并不实行任何实际的动作。它只是拥有一个name 以及与一个LoggerConfig相关联。它继承了AbstractLogger类并实现了所需的方法。当Configuration改变时,Logger将会与另外的LoggerConfig相关联,从而改变这个Logger的行为。

    获得Logger: 使用相同的名称参数来调用getLogger方法将获得来自同一个Logger的引用。
    如: Logger x = Logger.getLogger("wombat"); Logger y = Logger.getLogger("wombat"); x和y指向的是同一个Logger对象。
    log4j环境的配置是在应用的启动阶段完成的。优先进行的方式是通过读取配置文件来完成。
    log4j使采用类名(包括完整路径)来定义Logger 名变得很容易。这是一个很有用且很直接的Logger命名方式。使用这种方式命名可以很容易的定位这个log message产生的类的位置。
    当然,log4j也支持任意string的命名方式以满足开发者的需要。不过,使用类名来定义Logger名仍然是最为推崇的一种Logger命名方式。

    LoggerConfig

    当Logger在configuration中被描述时,LoggerConfig对象将被创建。LoggerConfig包含了一组过滤器。LogEvent在被传往Appender之前将先经过这些过滤器。过滤器中包含了一组Appender的引用。Appender则是用来处理这些LogEvent的。

    Log层次: 每一个LoggerConfig会被指定一个Log层次。可用的Log层次包括TRACE, DEBUG,INFO, WARN, ERROR 以及FATAL。

    需要注意的是,在log4j2中,Log的层次是一个Enum型变量,是不能继承或者修改的。如果希望获得跟多的分割粒度,可用考虑使用Markers来替代。

    在Log4j 1.x 和Logback 中都有“层次继承”这么个概念。

    但是在log4j2中,由于Logger和LoggerConfig是两种不同的对象,因此“层次继承”的概念实现起来跟Log4j 1.x 和Logback不同。

    LoggerContext

    LoggerContext在Logging System中扮演了锚点的角色。根据情况的不同,一个应用可能同时存在于多个有效的LoggerContext中。

    在同一LoggerContext下,log system是互通的。如:Standalone Application、Web Applications、Java EE Applications、"Shared" Web Applications 和REST Service Containers,就是不同广度范围的log上下文环境。

    Filter

    与防火墙过滤的规则相似,log4j2的过滤器也将返回三类状态:Accept(接受), Deny(拒绝) 或Neutral(中立)。

    其中,Accept意味着不用再调用其他过滤器了,这个LogEvent将被执行;
    Deny意味着马上忽略这个event,并将此event的控制权交还给过滤器的调用者;
    Neutral则意味着这个event应该传递给别的过滤器,如果再没有别的过滤器可以传递了,那么就由现在这个过滤器来处理。

    Appender

    由logger的不同来决定一个logging request是被禁用还是启用只是log4j2的情景之一。log4j2还允许将logging request中log信息打印到不同的目的地中。

    在log4j2的世界里,不同的输出位置被称为Appender。目前,Appender可以是console、文件、远程socket服务器、Apache Flume、JMS以及远程 UNIX 系统日志守护进程。

    一个Logger可以绑定多个不同的Appender。 可以调用当前Configuration的addLoggerAppender函数来为一个Logger增加。如果不存在一个与Logger名称相对应的LoggerConfig,那么相应的LoggerConfig将被创建,并且新增加的Appender将被添加到此新建的LoggerConfig中。而后,所有的Loggers将会被通知更新自己的LoggerConfig引用(PS:一个Logger的LoggerConfig引用是根据名称的匹配长度来决定的,当新的LoggerConfig被创建后,会引发一轮配对洗牌)。

    在某一个Logger中被启用的logging request将被转发到该Logger相关联的的所有Appenders上,并且还会被转发到LoggerConfig的父级的Appenders上。 这样会产生一连串的遗传效应。例如,对LoggerConfig B来说,它的父级为A,A的父级为root。如果在root中定义了一个Appender为console,那么所有启用了的logging request都会在console中打印出来。

    另外,如果LoggerConfig A定义了一个文件作为Appender,那么使用LoggerConfig A和LoggerConfig B的logger 的logging request都会在该文件中打印,并且同时在console中打印。 如果想避免这种遗传效应的话,可以在configuration文件中做如下设置: additivity="false" 这样,就可以关闭Appender的遗传效应了。

    目前支持的日志存放方式:
    123

    Layout

    通常,用户不止希望能定义log输出的位置,还希望可以定义输出的格式。这就可以通过将Appender与一个layout相关联来实现。

    Log4j中定义了一种类似C语言printf函数的打印格式,如"%r [%t] %-5p %c - %m%n" 格式在真实环境下会打印类似如下的信息: 176 [main] INFO org.foo.Bar - Located nearest gas station.

    其中,各个字段的含义分别是:
        %r 指的是程序运行至输出这句话所经过的时间(以毫秒为单位); 
        %t 指的是发起这一log request的线程; 
        %c 指的是log的level; 
        %m 指的是log request语句携带的message。 
        %n 为换行符。

    优先级

    log4j2中的日志一般分8个级别:ALL、TRACE、DEBUG、INFO、WARN、ERROR、FATAL、OFF。

    其中ALL为所有日志,OFF为关闭日志,所以,其实也就是6个级别:
        FATAL:用在极端的情形中,即必须马上获得注意的情况。这个程度的错误通常需要触发运维工程师的寻呼机。 
        ERROR:显示一个错误,或一个通用的错误情况,但还不至于会将系统挂起。这种程度的错误一般会触发邮件的发送,将消息发送到alert list中,运维人员可以在文档中记录这个bug并提交。 
        WARN:不一定是一个bug,但是有人可能会想要知道这一情况。如果有人在读log文件,他们通常会希望读到系统出现的任何警告。 
        INFO:用于基本的、高层次的诊断信息。在长时间运行的代码段开始运行及结束运行时应该产生消息,以便知道现在系统在干什么。但是这样的信息不宜太过频繁。 
        DEBUG:用于协助低层次的调试。 
        TRACE:用于展现程序执行的轨迹。 

    这8个级别优先级从低到高为:ALL<TRACE<DEBUG<INFO<WARN<ERROR<FATAL<OFF。

    当过滤器设置为某一级别时,会默认包含当前级别以及所有更高级别的log信息。

    2.2、部分输出方式介绍

    完整介绍请参考:http://logging.apache.org/log4j/2.x/manual/appenders.html

      2.2.1、控制台
<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);"><?</span><span class="pln" style="color: rgb(0, 0, 0);">xml version</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"1.0"</span><span class="pln" style="color: rgb(0, 0, 0);"> encoding</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"UTF-8"</span><span class="pun" style="color: rgb(102, 102, 0);">?></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"><Configuration</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">status</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"warn"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"MyApp"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">packages</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">""</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Appenders></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Console</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"STDOUT"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">target</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"SYSTEM_OUT"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"%m%n"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Console></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Appenders></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Loggers></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Root</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"error"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><AppenderRef</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"STDOUT"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Root></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Loggers></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"></Configuration></span></li></ol>
      2.2.2、log文件
<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);"><?</span><span class="pln" style="color: rgb(0, 0, 0);">xml version</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"1.0"</span><span class="pln" style="color: rgb(0, 0, 0);"> encoding</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"UTF-8"</span><span class="pun" style="color: rgb(102, 102, 0);">?></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"><Configuration</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">status</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"warn"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"MyApp"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">packages</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">""</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Appenders></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><File</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"MyFile"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"logs/app.log"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Pattern></span><span class="pln" style="color: rgb(0, 0, 0);">%d %p %c{1.} [%t] %m%n</span><span class="tag" style="color: rgb(0, 0, 136);"></Pattern></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></PatternLayout></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></File></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Appenders></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Loggers></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Root</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"error"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><AppenderRef</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"MyFile"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Root></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Loggers></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"></Configuration></span></li></ol>
      2.2.3、jdbc记录到数据库

    (1)

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);"><?</span><span class="pln" style="color: rgb(0, 0, 0);">xml version</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"1.0"</span><span class="pln" style="color: rgb(0, 0, 0);"> encoding</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"UTF-8"</span><span class="pun" style="color: rgb(102, 102, 0);">?></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"><Configuration</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">status</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"error"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Appenders></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><JDBC</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"databaseAppender"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">tableName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"dbo.application_log"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><DataSource</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">jndiName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"java:/comp/env/jdbc/LoggingDataSource"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Column</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"eventDate"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">isEventTimestamp</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"true"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Column</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"level"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"%level"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Column</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"logger"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"%logger"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Column</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"message"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"%message"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Column</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"exception"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"%ex{full}"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></JDBC></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Appenders></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Loggers></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Root</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"warn"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><AppenderRef</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"databaseAppender"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Root></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Loggers></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"></Configuration></span></li></ol>

    (2)

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);"><?</span><span class="pln" style="color: rgb(0, 0, 0);">xml version</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"1.0"</span><span class="pln" style="color: rgb(0, 0, 0);"> encoding</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"UTF-8"</span><span class="pun" style="color: rgb(102, 102, 0);">?></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"><Configuration</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">status</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"error"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Appenders></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><JDBC</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"databaseAppender"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">tableName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"LOGGING.APPLICATION_LOG"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ConnectionFactory</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">class</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"net.example.db.ConnectionFactory"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">method</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"getDatabaseConnection"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Column</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"EVENT_ID"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">literal</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"LOGGING.APPLICATION_LOG_SEQUENCE.NEXTVAL"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Column</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"EVENT_DATE"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">isEventTimestamp</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"true"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Column</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"LEVEL"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"%level"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Column</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"LOGGER"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"%logger"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Column</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"MESSAGE"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"%message"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Column</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"THROWABLE"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"%ex{full}"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></JDBC></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Appenders></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Loggers></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Root</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"warn"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><AppenderRef</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"databaseAppender"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Root></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Loggers></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"></Configuration></span></li></ol>

    

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">package</span><span class="pln" style="color: rgb(0, 0, 0);"> net</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">example</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">db</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">import</span><span class="pln" style="color: rgb(0, 0, 0);"> java</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">sql</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="typ" style="color: rgb(102, 0, 102);">Connection</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">import</span><span class="pln" style="color: rgb(0, 0, 0);"> java</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">sql</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="typ" style="color: rgb(102, 0, 102);">SQLException</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">import</span><span class="pln" style="color: rgb(0, 0, 0);"> java</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">util</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="typ" style="color: rgb(102, 0, 102);">Properties</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">import</span><span class="pln" style="color: rgb(0, 0, 0);"> javax</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">sql</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="typ" style="color: rgb(102, 0, 102);">DataSource</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">import</span><span class="pln" style="color: rgb(0, 0, 0);"> org</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">apache</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">commons</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">dbcp</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="typ" style="color: rgb(102, 0, 102);">DriverManagerConnectionFactory</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">import</span><span class="pln" style="color: rgb(0, 0, 0);"> org</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">apache</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">commons</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">dbcp</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="typ" style="color: rgb(102, 0, 102);">PoolableConnection</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">import</span><span class="pln" style="color: rgb(0, 0, 0);"> org</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">apache</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">commons</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">dbcp</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="typ" style="color: rgb(102, 0, 102);">PoolableConnectionFactory</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">import</span><span class="pln" style="color: rgb(0, 0, 0);"> org</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">apache</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">commons</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">dbcp</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="typ" style="color: rgb(102, 0, 102);">PoolingDataSource</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">import</span><span class="pln" style="color: rgb(0, 0, 0);"> org</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">apache</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">commons</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">pool</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">impl</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="typ" style="color: rgb(102, 0, 102);">GenericObjectPool</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">public</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">class</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">ConnectionFactory</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">{</span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">private</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">static</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">interface</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">Singleton</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">{</span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">final</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">ConnectionFactory</span><span class="pln" style="color: rgb(0, 0, 0);"> INSTANCE </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">new</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">ConnectionFactory</span><span class="pun" style="color: rgb(102, 102, 0);">();</span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">private</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">final</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">DataSource</span><span class="pln" style="color: rgb(0, 0, 0);"> dataSource</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">private</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">ConnectionFactory</span><span class="pun" style="color: rgb(102, 102, 0);">()</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">{</span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">Properties</span><span class="pln" style="color: rgb(0, 0, 0);"> properties </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">new</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">Properties</span><span class="pun" style="color: rgb(102, 102, 0);">();</span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">properties</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">setProperty</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"user"</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="str" style="color: rgb(0, 136, 0);">"logging"</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">properties</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">setProperty</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"password"</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="str" style="color: rgb(0, 136, 0);">"abc123"</span><span class="pun" style="color: rgb(102, 102, 0);">);</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="com" style="color: rgb(136, 0, 0);">// or get properties from some configuration file</span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">GenericObjectPool</span><span class="pun" style="color: rgb(102, 102, 0);"><</span><span class="typ" style="color: rgb(102, 0, 102);">PoolableConnection</span><span class="pun" style="color: rgb(102, 102, 0);">></span><span class="pln" style="color: rgb(0, 0, 0);"> pool </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">new</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">GenericObjectPool</span><span class="pun" style="color: rgb(102, 102, 0);"><</span><span class="typ" style="color: rgb(102, 0, 102);">PoolableConnection</span><span class="pun" style="color: rgb(102, 102, 0);">>();</span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">DriverManagerConnectionFactory</span><span class="pln" style="color: rgb(0, 0, 0);"> connectionFactory </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">new</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">DriverManagerConnectionFactory</span><span class="pun" style="color: rgb(102, 102, 0);">(</span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="str" style="color: rgb(0, 136, 0);">"jdbc:mysql://example.org:3306/exampleDb"</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> properties</span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">new</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">PoolableConnectionFactory</span><span class="pun" style="color: rgb(102, 102, 0);">(</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">connectionFactory</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> pool</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">null</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="str" style="color: rgb(0, 136, 0);">"SELECT 1"</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">3</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">false</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">false</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">Connection</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">TRANSACTION_READ_COMMITTED</span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">this</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">dataSource </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">new</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">PoolingDataSource</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">pool</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">public</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">static</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">Connection</span><span class="pln" style="color: rgb(0, 0, 0);"> getDatabaseConnection</span><span class="pun" style="color: rgb(102, 102, 0);">()</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">throws</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">SQLException</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">{</span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">return</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">Singleton</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">INSTANCE</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">dataSource</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">getConnection</span><span class="pun" style="color: rgb(102, 102, 0);">();</span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);">}</span></li></ol>

    2.2.4、压缩文件

    Below is a sample configuration that uses a RollingFileAppender with both the time and size based triggering policies, will create up to 7 archives on the same day (1-7) that are stored in a directory based on the current year and month, and will compress each archive using gzip:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);"><?</span><span class="pln" style="color: rgb(0, 0, 0);">xml version</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"1.0"</span><span class="pln" style="color: rgb(0, 0, 0);"> encoding</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"UTF-8"</span><span class="pun" style="color: rgb(102, 102, 0);">?></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"><Configuration</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">status</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"warn"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"MyApp"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">packages</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">""</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Appenders></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><RollingFile</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"RollingFile"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"logs/app.log"</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">filePattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Pattern></span><span class="pln" style="color: rgb(0, 0, 0);">%d %p %c{1.} [%t] %m%n</span><span class="tag" style="color: rgb(0, 0, 136);"></Pattern></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></PatternLayout></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Policies></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><TimeBasedTriggeringPolicy</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><SizeBasedTriggeringPolicy</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">size</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"250 MB"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Policies></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></RollingFile></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Appenders></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Loggers></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Root</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"error"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><AppenderRef</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"RollingFile"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Root></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Loggers></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"></Configuration></span></li></ol>

    This second example shows a rollover strategy that will keep up to 20 files before removing them:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);"><?</span><span class="pln" style="color: rgb(0, 0, 0);">xml version</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"1.0"</span><span class="pln" style="color: rgb(0, 0, 0);"> encoding</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"UTF-8"</span><span class="pun" style="color: rgb(102, 102, 0);">?></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"><Configuration</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">status</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"warn"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"MyApp"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">packages</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">""</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Appenders></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><RollingFile</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"RollingFile"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"logs/app.log"</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">filePattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Pattern></span><span class="pln" style="color: rgb(0, 0, 0);">%d %p %c{1.} [%t] %m%n</span><span class="tag" style="color: rgb(0, 0, 136);"></Pattern></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></PatternLayout></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Policies></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><TimeBasedTriggeringPolicy</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><SizeBasedTriggeringPolicy</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">size</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"250 MB"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Policies></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><DefaultRolloverStrategy</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">max</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"20"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></RollingFile></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Appenders></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Loggers></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Root</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"error"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><AppenderRef</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"RollingFile"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Root></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Loggers></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"></Configuration></span></li></ol>

    Below is a sample configuration that uses a RollingFileAppender with both the time and size based triggering policies, will create up to 7 archives on the same day (1-7) that are stored in a directory based on the current year and month, and will compress each archive using gzip and will roll every 6 hours when the hour is divisible by 6:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);"><?</span><span class="pln" style="color: rgb(0, 0, 0);">xml version</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"1.0"</span><span class="pln" style="color: rgb(0, 0, 0);"> encoding</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"UTF-8"</span><span class="pun" style="color: rgb(102, 102, 0);">?></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"><Configuration</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">status</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"warn"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"MyApp"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">packages</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">""</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Appenders></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><RollingFile</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"RollingFile"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"logs/app.log"</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">filePattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"logs/$${date:yyyy-MM}/app-%d{yyyy-MM-dd-HH}-%i.log.gz"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Pattern></span><span class="pln" style="color: rgb(0, 0, 0);">%d %p %c{1.} [%t] %m%n</span><span class="tag" style="color: rgb(0, 0, 136);"></Pattern></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></PatternLayout></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Policies></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><TimeBasedTriggeringPolicy</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">interval</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"6"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">modulate</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"true"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><SizeBasedTriggeringPolicy</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">size</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"250 MB"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Policies></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></RollingFile></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Appenders></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Loggers></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Root</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"error"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><AppenderRef</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"RollingFile"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Root></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Loggers></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"></Configuration></span></li></ol>

    Below is a sample configuration that uses a RollingFileAppender with the cron triggering policy configured to trigger every day at midnight. Archives are stored in a directory based on the current year and month. All files under the base directory that match the "*/app-*.log.gz" glob and are 60 days old or older are deleted at rollover time:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);"><?</span><span class="pln" style="color: rgb(0, 0, 0);">xml version</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"1.0"</span><span class="pln" style="color: rgb(0, 0, 0);"> encoding</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"UTF-8"</span><span class="pun" style="color: rgb(102, 102, 0);">?></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"><Configuration</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">status</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"warn"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"MyApp"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">packages</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">""</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Properties></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Property</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"baseDir"</span><span class="tag" style="color: rgb(0, 0, 136);">></span><span class="pln" style="color: rgb(0, 0, 0);">logs</span><span class="tag" style="color: rgb(0, 0, 136);"></Property></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Properties></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Appenders></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><RollingFile</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"RollingFile"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${baseDir}/app.log"</span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">filePattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${baseDir}/$${date:yyyy-MM}/app-%d{yyyy-MM-dd}.log.gz"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"%d %p %c{1.} [%t] %m%n"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><CronTriggeringPolicy</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">schedule</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"0 0 0 * * ?"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><DefaultRolloverStrategy></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Delete</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">basePath</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${baseDir}"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">maxDepth</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"2"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><IfFileName</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">glob</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"*/app-*.log.gz"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><IfLastModified</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">age</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"60d"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Delete></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></DefaultRolloverStrategy></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></RollingFile></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Appenders></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Loggers></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Root</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"error"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><AppenderRef</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"RollingFile"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Root></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Loggers></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"></Configuration></span></li></ol>

    Below is a sample configuration that uses a RollingFileAppender with both the time and size based triggering policies, will create up to 100 archives on the same day (1-100) that are stored in a directory based on the current year and month, and will compress each archive using gzip and will roll every hour. During every rollover, this configuration will delete files that match "*/app-*.log.gz" and are 30 days old or older, but keep the most recent 100 GB or the most recent 10 files, whichever comes first:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);"><?</span><span class="pln" style="color: rgb(0, 0, 0);">xml version</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"1.0"</span><span class="pln" style="color: rgb(0, 0, 0);"> encoding</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"UTF-8"</span><span class="pun" style="color: rgb(102, 102, 0);">?></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"><Configuration</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">status</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"warn"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"MyApp"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">packages</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">""</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Properties></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Property</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"baseDir"</span><span class="tag" style="color: rgb(0, 0, 136);">></span><span class="pln" style="color: rgb(0, 0, 0);">logs</span><span class="tag" style="color: rgb(0, 0, 136);"></Property></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Properties></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Appenders></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><RollingFile</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"RollingFile"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${baseDir}/app.log"</span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">filePattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${baseDir}/$${date:yyyy-MM}/app-%d{yyyy-MM-dd-HH}-%i.log.gz"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"%d %p %c{1.} [%t] %m%n"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Policies></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><TimeBasedTriggeringPolicy</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><SizeBasedTriggeringPolicy</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">size</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"250 MB"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Policies></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><DefaultRolloverStrategy</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">max</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"100"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="com" style="color: rgb(136, 0, 0);"><!--</span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="com" style="color: rgb(136, 0, 0);">--></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Delete</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">basePath</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${baseDir}"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">maxDepth</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"2"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><IfFileName</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">glob</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"*/app-*.log.gz"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><IfLastModified</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">age</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"30d"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><IfAny></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><IfAccumulatedFileSize</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">exceeds</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"100 GB"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><IfAccumulatedFileCount</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">exceeds</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"10"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></IfAny></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></IfLastModified></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></IfFileName></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Delete></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></DefaultRolloverStrategy></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></RollingFile></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Appenders></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Loggers></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Root</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"error"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><AppenderRef</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"RollingFile"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Root></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Loggers></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"></Configuration></span></li></ol>

    Below is a sample configuration that uses a RollingFileAppender with the cron triggering policy configured to trigger every day at midnight. Archives are stored in a directory based on the current year and month. The script returns a list of rolled over files under the base directory dated Friday the 13th. The Delete action will delete all files returned by the script:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);"><?</span><span class="pln" style="color: rgb(0, 0, 0);">xml version</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"1.0"</span><span class="pln" style="color: rgb(0, 0, 0);"> encoding</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="str" style="color: rgb(0, 136, 0);">"UTF-8"</span><span class="pun" style="color: rgb(102, 102, 0);">?></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"><Configuration</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">status</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"trace"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"MyApp"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">packages</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">""</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Properties></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Property</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"baseDir"</span><span class="tag" style="color: rgb(0, 0, 136);">></span><span class="pln" style="color: rgb(0, 0, 0);">logs</span><span class="tag" style="color: rgb(0, 0, 136);"></Property></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Properties></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Appenders></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><RollingFile</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"RollingFile"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${baseDir}/app.log"</span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">filePattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${baseDir}/$${date:yyyy-MM}/app-%d{yyyyMMdd}.log.gz"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"%d %p %c{1.} [%t] %m%n"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><CronTriggeringPolicy</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">schedule</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"0 0 0 * * ?"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><DefaultRolloverStrategy></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Delete</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">basePath</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${baseDir}"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">maxDepth</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"2"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ScriptCondition></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Script</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"superstitious"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">language</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"groovy"</span><span class="tag" style="color: rgb(0, 0, 136);">></span><span class="pun" style="color: rgb(102, 102, 0);"><![</span><span class="pln" style="color: rgb(0, 0, 0);">CDATA</span><span class="pun" style="color: rgb(102, 102, 0);">[</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">import</span><span class="pln" style="color: rgb(0, 0, 0);"> java</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">nio</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">file</span><span class="pun" style="color: rgb(102, 102, 0);">.*;</span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">def result </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">[];</span><span class="pln" style="color: rgb(0, 0, 0);"></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">def pattern </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">~</span><span class="str" style="color: rgb(0, 136, 0);">/\d*\/app-(\d*)\.log\.gz/</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">pathList</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">each </span><span class="pun" style="color: rgb(102, 102, 0);">{</span><span class="pln" style="color: rgb(0, 0, 0);"> pathWithAttributes </span><span class="pun" style="color: rgb(102, 102, 0);">-></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">def relative </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> basePath</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">relativize pathWithAttributes</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">path</span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">statusLogger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">trace </span><span class="str" style="color: rgb(0, 136, 0);">'SCRIPT: relative path='</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">+</span><span class="pln" style="color: rgb(0, 0, 0);"> relative </span><span class="pun" style="color: rgb(102, 102, 0);">+</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="str" style="color: rgb(0, 136, 0);">" (base=$basePath)"</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="com" style="color: rgb(136, 0, 0);">// remove files dated Friday the 13th</span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">def matcher </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> pattern</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">matcher</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">relative</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">toString</span><span class="pun" style="color: rgb(102, 102, 0);">());</span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">if</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">matcher</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">find</span><span class="pun" style="color: rgb(102, 102, 0);">())</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">{</span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">def dateString </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> matcher</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">group</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="lit" style="color: rgb(0, 102, 102);">1</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">def calendar </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">Date</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">parse</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"yyyyMMdd"</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);"> dateString</span><span class="pun" style="color: rgb(102, 102, 0);">).</span><span class="pln" style="color: rgb(0, 0, 0);">toCalendar</span><span class="pun" style="color: rgb(102, 102, 0);">();</span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">def friday13th </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> calendar</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="kwd" style="color: rgb(0, 0, 136);">get</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="typ" style="color: rgb(102, 0, 102);">Calendar</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">DAY_OF_MONTH</span><span class="pun" style="color: rgb(102, 102, 0);">)</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">==</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">13</span><span class="pln" style="color: rgb(0, 0, 0);"> \</span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">&&</span><span class="pln" style="color: rgb(0, 0, 0);"> calendar</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="kwd" style="color: rgb(0, 0, 136);">get</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="typ" style="color: rgb(102, 0, 102);">Calendar</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">DAY_OF_WEEK</span><span class="pun" style="color: rgb(102, 102, 0);">)</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">==</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">Calendar</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">FRIDAY</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">if</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">friday13th</span><span class="pun" style="color: rgb(102, 102, 0);">)</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">{</span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">result</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">add pathWithAttributes</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">statusLogger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">trace </span><span class="str" style="color: rgb(0, 136, 0);">'SCRIPT: deleting path '</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">+</span><span class="pln" style="color: rgb(0, 0, 0);"> pathWithAttributes</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">statusLogger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">trace </span><span class="str" style="color: rgb(0, 136, 0);">'SCRIPT: returning '</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">+</span><span class="pln" style="color: rgb(0, 0, 0);"> result</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">result</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">]]</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Script></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></ScriptCondition></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Delete></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></DefaultRolloverStrategy></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></RollingFile></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Appenders></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Loggers></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Root</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"error"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><AppenderRef</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"RollingFile"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Root></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Loggers></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"></Configuration></span></li></ol>

    请原谅我...翻译得好累。只怪我当初没好好学英语,不过读懂问题还是不大。

3、集成log4j2到Spring4 MVC+Hibernate5工程

    3.1、添加依赖(jar包):

      3.1.1、传统工程方式

    下载jar包, 官方下载地址:http://logging.apache.org/log4j/2.x/download

1

    下载解压即可看到需要的jar包:

    2

    这里,我们需要这3个jar包:

        3

    直接拖到eclipse中lib目录下即可。

      3.1.2、Maven工程方式

    这种方式很简单,只需要在pom.xml文件中如下添加依赖:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><dependency></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><groupId></span><span class="pln" style="color: rgb(0, 0, 0);">org.apache.logging.log4j</span><span class="tag" style="color: rgb(0, 0, 136);"></groupId></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><artifactId></span><span class="pln" style="color: rgb(0, 0, 0);">log4j-api</span><span class="tag" style="color: rgb(0, 0, 136);"></artifactId></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><version></span><span class="pln" style="color: rgb(0, 0, 0);">2.5</span><span class="tag" style="color: rgb(0, 0, 136);"></version></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></dependency></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><dependency></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><groupId></span><span class="pln" style="color: rgb(0, 0, 0);">org.apache.logging.log4j</span><span class="tag" style="color: rgb(0, 0, 136);"></groupId></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><artifactId></span><span class="pln" style="color: rgb(0, 0, 0);">log4j-core</span><span class="tag" style="color: rgb(0, 0, 136);"></artifactId></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><version></span><span class="pln" style="color: rgb(0, 0, 0);">2.5</span><span class="tag" style="color: rgb(0, 0, 136);"></version></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></dependency></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><dependency></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><groupId></span><span class="pln" style="color: rgb(0, 0, 0);">org.apache.logging.log4j</span><span class="tag" style="color: rgb(0, 0, 136);"></groupId></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><artifactId></span><span class="pln" style="color: rgb(0, 0, 0);">log4j-web</span><span class="tag" style="color: rgb(0, 0, 136);"></artifactId></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><version></span><span class="pln" style="color: rgb(0, 0, 0);">2.5</span><span class="tag" style="color: rgb(0, 0, 136);"></version></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><scope></span><span class="pln" style="color: rgb(0, 0, 0);">runtime</span><span class="tag" style="color: rgb(0, 0, 136);"></scope></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></dependency></span></li></ol>

    3.2、配置

    请在web.xml中添加如下代码:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><context-param></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><param-name></span><span class="pln" style="color: rgb(0, 0, 0);">isLog4jAutoInitializationDisabled</span><span class="tag" style="color: rgb(0, 0, 136);"></param-name></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><param-value></span><span class="pln" style="color: rgb(0, 0, 0);">false</span><span class="tag" style="color: rgb(0, 0, 136);"></param-value></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></context-param></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><context-param></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><param-name></span><span class="pln" style="color: rgb(0, 0, 0);">log4jConfiguration</span><span class="tag" style="color: rgb(0, 0, 136);"></param-name></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><param-value></span><span class="pln" style="color: rgb(0, 0, 0);">classpath:config/log4j2.xml</span><span class="tag" style="color: rgb(0, 0, 136);"></param-value></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></context-param></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><listener></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><listener-class></span><span class="pln" style="color: rgb(0, 0, 0);">org.apache.logging.log4j.web.Log4jServletContextListener</span><span class="tag" style="color: rgb(0, 0, 136);"></listener-class></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></listener></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><filter></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><filter-name></span><span class="pln" style="color: rgb(0, 0, 0);">log4jServletFilter</span><span class="tag" style="color: rgb(0, 0, 136);"></filter-name></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><filter-class></span><span class="pln" style="color: rgb(0, 0, 0);">org.apache.logging.log4j.web.Log4jServletFilter</span><span class="tag" style="color: rgb(0, 0, 136);"></filter-class></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></filter></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><filter-mapping></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><filter-name></span><span class="pln" style="color: rgb(0, 0, 0);">log4jServletFilter</span><span class="tag" style="color: rgb(0, 0, 136);"></filter-name></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><url-pattern></span><span class="pln" style="color: rgb(0, 0, 0);">/*</span><span class="tag" style="color: rgb(0, 0, 136);"></url-pattern></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><dispatcher></span><span class="pln" style="color: rgb(0, 0, 0);">REQUEST</span><span class="tag" style="color: rgb(0, 0, 136);"></dispatcher></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><dispatcher></span><span class="pln" style="color: rgb(0, 0, 0);">FORWARD</span><span class="tag" style="color: rgb(0, 0, 136);"></dispatcher></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><dispatcher></span><span class="pln" style="color: rgb(0, 0, 0);">INCLUDE</span><span class="tag" style="color: rgb(0, 0, 136);"></dispatcher></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><dispatcher></span><span class="pln" style="color: rgb(0, 0, 0);">ERROR</span><span class="tag" style="color: rgb(0, 0, 136);"></dispatcher></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></filter-mapping></span></li></ol>

    log4jConfiguration为log4j2的配置文件位置。

    编辑配置(若配置文件不存在则新建),配置为每个不同级别的输出到不同文件,并增加一个按单文件大小自动压缩的日志:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"><configuration</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">status</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"off"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">debug</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"off"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">monitorInterval</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"1800"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Properties></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Property</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"log_path"</span><span class="tag" style="color: rgb(0, 0, 136);">></span><span class="pln" style="color: rgb(0, 0, 0);">d://logs</span><span class="tag" style="color: rgb(0, 0, 136);"></Property></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><property</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"log_file"</span><span class="tag" style="color: rgb(0, 0, 136);">></span><span class="pln" style="color: rgb(0, 0, 0);">%d{yyyy-MM-dd HH:mm:ss z} %-5level %class{36} %L %M - %msg%xEx%n</span><span class="tag" style="color: rgb(0, 0, 136);"></property></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><property</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"log_console"</span><span class="tag" style="color: rgb(0, 0, 136);">></span><span class="pln" style="color: rgb(0, 0, 0);">%d{HH:mm:ss.SSS z} %-5level %class{36}.%M()/%L - %msg%xEx%n</span><span class="tag" style="color: rgb(0, 0, 136);"></property></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><property</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"every_file_size"</span><span class="tag" style="color: rgb(0, 0, 136);">></span><span class="pln" style="color: rgb(0, 0, 0);">10M</span><span class="tag" style="color: rgb(0, 0, 136);"></property></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Properties></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Appenders></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Console</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"Console"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">target</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"SYSTEM_OUT"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ThresholdFilter</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"all"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">ACCEPT</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMismatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">DENY</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_console}"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Console></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><File</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"app_all"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_path}/all.log"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">append</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"false"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Filters></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ThresholdFilter</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"all"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">ACCEPT</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMismatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">DENY</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Filters></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_file}"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></File></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><File</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"app_trace"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_path}/trace.log"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">append</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"false"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Filters></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ThresholdFilter</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"debug"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">DENY</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMismatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">NEUTRAL</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ThresholdFilter</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"trace"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">ACCEPT</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMismatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">DENY</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Filters></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_file}"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></File></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><File</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"app_debug"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_path}/debug.log"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">append</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"false"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Filters></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ThresholdFilter</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"info"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">DENY</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMismatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">NEUTRAL</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ThresholdFilter</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"debug"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">ACCEPT</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMismatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">DENY</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Filters></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_file}"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></File></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><File</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"app_info"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_path}/info.log"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">append</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"false"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Filters></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ThresholdFilter</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"warn"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">DENY</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMismatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">NEUTRAL</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ThresholdFilter</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"info"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">ACCEPT</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMismatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">DENY</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Filters></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_file}"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></File></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><File</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"app_warn"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_path}/warn.log"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">append</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"false"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Filters></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ThresholdFilter</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"error"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">DENY</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMismatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">NEUTRAL</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ThresholdFilter</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"warn"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">ACCEPT</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMismatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">DENY</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Filters></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_file}"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></File></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><File</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"app_error"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_path}/error.log"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">append</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"false"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Filters></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ThresholdFilter</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"fatal"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">DENY</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMismatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">NEUTRAL</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ThresholdFilter</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"error"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">ACCEPT</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMismatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">DENY</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Filters></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_file}"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></File></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><File</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"app_fatal"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_path}/fatal.log"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">append</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"false"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Filters></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ThresholdFilter</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"fatal"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">ACCEPT</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMismatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">DENY</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Filters></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_file}"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></File></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><RollingFile</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"RollingFile"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">fileName</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_path}/app.log"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">filePattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_path}/app-%d{yyyy-MM-dd}-%i.log.gz"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><PatternLayout</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">pattern</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${log_file}"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><SizeBasedTriggeringPolicy</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">size</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"${every_file_size}"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Filters></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><ThresholdFilter</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"all"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">ACCEPT</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">onMismatch</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="pln" style="color: rgb(0, 0, 0);">DENY</span><span class="atv" style="color: rgb(0, 136, 0);">"</span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Filters></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></RollingFile></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Appenders></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Loggers></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><Logger</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">name</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"com.anxpp.demo"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">level</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"all"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">additivity</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"false"</span><span class="tag" style="color: rgb(0, 0, 136);">></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><appender-ref</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"Console"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><appender-ref</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"app_all"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><appender-ref</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"app_trace"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><appender-ref</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"app_debug"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><appender-ref</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"app_info"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><appender-ref</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"app_warn"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><appender-ref</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"app_error"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><appender-ref</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"app_fatal"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"><appender-ref</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="atn" style="color: rgb(102, 0, 102);">ref</span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="atv" style="color: rgb(0, 136, 0);">"RollingFile"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);">/></span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Logger></span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="tag" style="color: rgb(0, 0, 136);"></Loggers></span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="tag" style="color: rgb(0, 0, 136);"></configuration></span></li></ol>

   

4、log4j的使用

    log4j使用很简单:

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="kwd" style="color: rgb(0, 0, 136);">public</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">class</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">DemoController</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">{</span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">private</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">static</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">final</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">Logger</span><span class="pln" style="color: rgb(0, 0, 0);"> logger </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">LogManager</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">getLogger</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="typ" style="color: rgb(102, 0, 102);">DemoController</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="kwd" style="color: rgb(0, 0, 136);">class</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">public</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">String</span><span class="pln" style="color: rgb(0, 0, 0);"> test</span><span class="pun" style="color: rgb(102, 102, 0);">(){</span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">logger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">trace</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"trace"</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">return</span><span class="pln" style="color: rgb(0, 0, 0);"> demoService</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">test</span><span class="pun" style="color: rgb(102, 102, 0);">();</span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pun" style="color: rgb(102, 102, 0);">}</span></li></ol>

    可以看到,只需要调用一个很简单的方法即可。

    接下来我们在项目中使用以下代码测试(我们先将log4j2.xml文件中压缩的单个文件大小改为1M方便查看):

<ol class="linenums" style="margin: 0px; color: rgb(43, 165, 216); list-style-position: outside;"><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">private</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">static</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">final</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">Logger</span><span class="pln" style="color: rgb(0, 0, 0);"> logger </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">LogManager</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">getLogger</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="typ" style="color: rgb(102, 0, 102);">DemoConreoller</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="kwd" style="color: rgb(0, 0, 136);">class</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">@RequestMapping</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"/"</span><span class="pun" style="color: rgb(102, 102, 0);">)</span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">public</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">String</span><span class="pln" style="color: rgb(0, 0, 0);"> index</span><span class="pun" style="color: rgb(102, 102, 0);">(){</span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">logger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">trace</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"index"</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">return</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="str" style="color: rgb(0, 136, 0);">"index"</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">@RequestMapping</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"/test"</span><span class="pun" style="color: rgb(102, 102, 0);">)</span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">@ResponseBody</span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">public</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">String</span><span class="pln" style="color: rgb(0, 0, 0);"> testRerutnString</span><span class="pun" style="color: rgb(102, 102, 0);">(){</span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">int</span><span class="pln" style="color: rgb(0, 0, 0);"> i </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">50000</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L0" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">while</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">i</span><span class="pun" style="color: rgb(102, 102, 0);">--></span><span class="lit" style="color: rgb(0, 102, 102);">0</span><span class="pun" style="color: rgb(102, 102, 0);">){</span></li><li class="L1" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">logger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">trace</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"trace"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">+</span><span class="pln" style="color: rgb(0, 0, 0);"> i</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L2" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">logger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">debug</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"debug"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">+</span><span class="pln" style="color: rgb(0, 0, 0);"> i</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L3" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">logger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">info</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"info"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">+</span><span class="pln" style="color: rgb(0, 0, 0);"> i</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L4" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">logger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">warn</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"warn"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">+</span><span class="pln" style="color: rgb(0, 0, 0);"> i</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L5" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">logger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">error</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"error"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">+</span><span class="pln" style="color: rgb(0, 0, 0);"> i</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L6" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);">logger</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);">fatal</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"fatal"</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">+</span><span class="pln" style="color: rgb(0, 0, 0);"> i</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L7" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L8" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">return</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="str" style="color: rgb(0, 136, 0);">"Hello Word!"</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L9" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(209, 215, 220); padding: 0px 5px; line-height: 23px; background-color: rgb(250, 250, 250);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li></ol>

    运行项目后分别访问/和test:

05

    然后查看log日志文件:

06

    可以看到压缩文件大小为30K,我们设置的是1M,那就对了,log文件在压缩前是单个达到1M时就压缩,压缩完自然就变小了。

    再看看内容:

06

    内容如我们配置的一样,格式与控制台输出的稍微不同。

5、项目源码下载

    以下工程都是基于Spring4+Hibernate5集成Log4j2的。

    5.1、Maven工程下载:

    Spring4Hibernate5Log4j2MVC.7z(大小:12k)

    5.2、传统工程下载:

    Spring4Hibernate5SpringMVCLog4j2.7z(大小:15.4M)

    两个工程压缩包大小有如此的差别,归功于maven,将所有的jar包依赖放到了pom.xml文件中。

1 0