首页新闻招聘找找看知识库

下面的log4j.xml文件哪里设置的有问题?怎么IDEA log.info打出的中文是乱码?

0
悬赏园豆:10 [已解决问题] 解决于 2018-04-21 09:54
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" 
    "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd" >
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
         <param name="encoding" value="UTF-8" /> 
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss}--%p %l%n  %m%n"/>
        </layout>
        <filter class="org.apache.log4j.varia.LevelRangeFilter">
            <param name="LevelMax" value="ERROR" />
            <param name="LevelMin" value="DEBUG" />
            <param name="AcceptOnMatch" value="true" />
        </filter>
    </appender>

    <appender name="INFO" class="org.apache.log4j.DailyRollingFileAppender">
         <param name="encoding" value="UTF-8" />
        <param name="DatePattern" value="'_'yyyy-MM-dd'.log'"/>
         <param name="File" value="/log/xxx.log"/>
        <param name="Append" value="true"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss}--%p %l%n  %m%n"/>
        </layout>
        <filter class="org.apache.log4j.varia.LevelRangeFilter">
            <param name="LevelMax" value="INFO" />
            <param name="LevelMin" value="INFO" />
        </filter>
    </appender>
    
    <appender name="ERROR" class="org.apache.log4j.DailyRollingFileAppender">
         <param name="encoding" value="UTF-8" /> 
        <param name="DatePattern" value="'_'yyyy-MM-dd'.log'"/>
         <param name="File" value="/log/xxx.log"/>
        <param name="Append" value="true"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss}--%p %l%n  %m%n"/>
        </layout>
        <filter class="org.apache.log4j.varia.LevelRangeFilter">
            <param name="LevelMax" value="ERROR" />
            <param name="LevelMin" value="WARN" />
        </filter>
    </appender>
    
    <category name="org.springframework">
        <priority value="error" />
        <appender-ref ref="CONSOLE" />
        <appender-ref ref="ERROR" />
    </category>
    
    <logger name="com.xxxx.data.mapper.xxxtMapper.updateCart">
        <level value="DEBUG"></level>
        <appender-ref ref="CONSOLE"/>
    </logger>
    
    <root>
        <appender-ref ref="CONSOLE"/>
        <appender-ref ref="INFO"/>
        <appender-ref ref="ERROR"/>
    </root>
</log4j:configuration>
OSManager的主页 OSManager | 初学一级 | 园豆:45
提问于:2018-04-16 01:27
< >
分享
最佳答案
0

idea的其他地方也需要设置utf-8

https://www.cnblogs.com/liaoyanglong/p/6639039.html 有的设置过tomcat,可以参考

收获园豆:10
2012 | 专家六级 |园豆:16879 | 2018-04-16 08:27
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册