如何在apache MINA中禁用SslFilter日志记录?

时间:2010-11-01 22:25:23

标签: logging apache-mina

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

1 个答案:

答案 0 :(得分: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>