从log4j.xml配置log4j2.xml

时间:2017-06-14 10:59:49

标签: log4j upgrade log4j2

目前我正在将log4j版本从1.2.17升级到2.8.2,为此我需要配置log4j2.xml,如何将下面提到的log4j.xml文件转换为log4j2.xml?

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
  <appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
    <layout class="org.apache.log4j.SimpleLayout" />
  </appender>
  <appender name="RootFileAppender" class="org.apache.log4j.RollingFileAppender">
    <param name="File" value="logs/webuif.log" />
    <param name="MaxFileSize" value="10MB" />
    <param name="MaxBackupIndex" value="10" />
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%p %c: %m%n" />
    </layout>
  </appender>
  <appender name="ApplicationFileAppender" class="org.apache.log4j.RollingFileAppender">
    <param name="File" value="logs/ab.log" />
    <param name="MaxFileSize" value="10MB" />
    <param name="MaxBackupIndex" value="10" />
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%p %c: %m%n" />
    </layout>
  </appender>
  <category name="com.abc" additivity="false">
    <priority value="debug" />
    <appender-ref ref="ApplicationFileAppender" />
    <appender-ref ref="ConsoleAppender" />
  </category>
  <root>
    <priority value="warn" />
    <appender-ref ref="ConsoleAppender" />
    <appender-ref ref="RootFileAppender" />
  </root>
</log4j:configuration>

0 个答案:

没有答案