1

我正在开发基于 apache MINA 的应用程序。为了安全的数据传输,我使用 SSL。并且出现了一些烦人的事情:当我收到传入消息时,SslFilter 类将大约 10kbytes 附加到日志文件中。我怎样才能防止这种情况?

4

1 回答 1

1

我终于找到了解决这个问题的方法。这是 log4j.xml 源代码:

<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
  <appender name="CONSOLE-DEBUG" class="org.apache.log4j.ConsoleAppender">
    <param name="target" value="System.out"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d{ISO8601} [%5p] %m at %l%n"/>
    </layout>
    <filter class="org.apache.log4j.varia.LevelRangeFilter">
      <param name="LevelMin" value="ALL"/>
      <param name="LevelMax" value="INFO"/>
    </filter>
  </appender>
  <appender name="CONSOLE-WARN" class="org.apache.log4j.ConsoleAppender">
    <param name="target" value="System.err"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d{ISO8601} [%5p] %m at %l%n"/>
    </layout>
    <filter class="org.apache.log4j.varia.LevelRangeFilter">
      <param name="LevelMin" value="WARN"/>
    </filter>
  </appender>
  <appender name="LOG-FILE-APPENDER" class="org.apache.log4j.FileAppender">
    <param name="file" value="app.log"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d{ISO8601} [%5p] %c %m at %l%n"/>
    </layout>
  </appender>
  <category name="org.apache.mina.filter.ssl.SslHandler" additivity="false">
    <priority value="ERROR"/>
    <appender-ref ref="LOG-FILE-APPENDER"/>
  </category>
  <category name="org.apache.mina.filter.ssl.SslFilter" additivity="false">
    <priority value="ERROR"/>
    <appender-ref ref="LOG-FILE-APPENDER"/>
  </category>
  <root>
    <priority value="DEBUG"/>
    <appender-ref ref="CONSOLE-WARN"/>
    <appender-ref ref="CONSOLE-DEBUG"/>
    <appender-ref ref="LOG-FILE-APPENDER"/>
  </root>
</log4j:configuration>
于 2010-11-04T20:17:11.107 回答