OpenFire控制台输出日志

原创
2016/01/13 23:52
阅读数 65

开发openfire插件时,调试时看不到日志,很是蛋疼。不过修改\build\lib\dist\log4j.xml就可以在控制台打印日志,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="STDOUT" class="org.apache.log4j.ConsoleAppender">  
        <layout class="org.apache.log4j.PatternLayout">  
            <param name="ConversionPattern" value="%-5p %d{yyyy-MM-dd HH:mm:ss}   %c{1}:%L - %m%n" />  
        </layout>  
    </appender>  
  
    <appender name="debug-out" class="org.apache.log4j.RollingFileAppender">  
        <param name="File" value="${openfireHome}/logs/debug.log" />  
        <param name="MaxFileSize" value="1024KB" />  
        <param name="MaxBackupIndex" value="5" />  
        <layout class="org.apache.log4j.PatternLayout">  
            <param name="ConversionPattern" value="%d{yyyy.MM.dd HH:mm:ss} %c - %m%n" />  
        </layout>  
        <filter class="org.apache.log4j.varia.LevelRangeFilter">  
            <param name="LevelMax" value="debug" />  
            <param name="AcceptOnMatch" value="true" />  
        </filter>  
    </appender>  
  
    <appender name="info-out" class="org.apache.log4j.RollingFileAppender">  
        <param name="File" value="${openfireHome}/logs/info.log" />  
        <param name="MaxFileSize" value="1024KB" />  
        <param name="MaxBackupIndex" value="5" />  
        <layout class="org.apache.log4j.PatternLayout">  
            <param name="ConversionPattern" value="%d{yyyy.MM.dd HH:mm:ss} %c - %m%n" />  
        </layout>  
        <filter class="org.apache.log4j.varia.LevelRangeFilter">  
            <param name="LevelMax" value="info" />  
            <param name="LevelMin" value="info" />  
            <param name="AcceptOnMatch" value="true" />  
        </filter>  
    </appender>  
  
    <appender name="warn-out" class="org.apache.log4j.RollingFileAppender">  
        <param name="File" value="${openfireHome}/logs/warn.log" />  
        <param name="MaxFileSize" value="1024KB" />  
        <param name="MaxBackupIndex" value="5" />  
        <layout class="org.apache.log4j.PatternLayout">  
            <param name="ConversionPattern" value="%d{yyyy.MM.dd HH:mm:ss} %c - %m%n" />  
        </layout>  
        <filter class="org.apache.log4j.varia.LevelRangeFilter">  
            <param name="LevelMax" value="warn" />  
            <param name="LevelMin" value="warn" />  
            <param name="AcceptOnMatch" value="true" />  
        </filter>  
    </appender>  
  
    <appender name="error-out" class="org.apache.log4j.RollingFileAppender">  
        <param name="File" value="${openfireHome}/logs/error.log" />  
        <param name="MaxFileSize" value="1024KB" />  
        <param name="MaxBackupIndex" value="5" />  
        <layout class="org.apache.log4j.PatternLayout">  
            <param name="ConversionPattern" value="%d{yyyy.MM.dd HH:mm:ss} %c - %m%n" />  
        </layout>  
        <filter class="org.apache.log4j.varia.LevelRangeFilter">  
            <param name="LevelMin" value="error" />  
            <param name="AcceptOnMatch" value="true" />  
        </filter>  
    </appender>  
   
    <logger name="org.eclipse.jetty">  
        <level value="warn" />  
    </logger>  
  
     
    <logger name="java.sql.Connection">  
        <level value="DEBUG" />  
    </logger>  

    <root>  
        <level value="info" />  
        <appender-ref ref="STDOUT" />  
        <appender-ref ref="debug-out" />  
        <appender-ref ref="info-out" />  
        <appender-ref ref="warn-out" />  
        <appender-ref ref="error-out" />  
    </root>  
  
</log4j:configuration>


展开阅读全文
打赏
1
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
1
分享
在线直播报名
返回顶部
顶部