0

我有 log4j 配置文件,它似乎适用于正常流程,但是在批处理时它不起作用,不确定必须在特定于批处理的配置文件中添加什么。请帮助解决这个问题

<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="C:\Users\Logs.log" />
............
<layout class="org.apache.log4j.PatternLayout">    
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
    <param name="LevelMin" value="INFO" />
    <param name="LevelMax" value="FATAL" />
    <param name="AcceptOnMatch" value="true" />
</filter>
<root>
<appender-ref ref="FILE" />
</root>

我发现这样的博客log4j.logger.com.mulesoft.module.batch=INFO。我不确定必须在上面的 xml 中添加哪些特定于批处理的所有配置。我们对Log4j Mule ESB中的批处理有什么特殊配置吗?我不确定如何批量执行。提前致谢。

4

1 回答 1

0

在您的 log4j.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="rolling-out" class="org.apache.log4j.RollingFileAppender">
        <param name="Threshold" value="info" />
        <param name="File" value="C:/Users/Logs.log" />
        <param name="Append" value="true" />
        <param name="MaxFileSize" value="10000KB" />
        <param name="MaxBackupIndex" value="3" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="[%d] [%-5p] [%t] %m%n"/>
        </layout>
    </appender> 

    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
        <param name="Threshold" value="info" />
        <param name="Target" value="System.out" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="[%d] [%-5p] [%t] %m%n"/>
        </layout>
    </appender>

    <logger name="log4j.logger.com.gigaspaces"> 
        <level value="ERROR" /> 
        <appender-ref ref="rolling-out" />
    </logger>

        <logger name="log4j.logger.com.j_spaces">           
        <level value="ERROR" /> 
        <appender-ref ref="rolling-out" />
    </logger>

    <logger name="log4j.logger.com.sun.jini">           
        <level value="ERROR" /> 
        <appender-ref ref="rolling-out" />
    </logger>

    <logger name="log4j.logger.net.jini">           
        <level value="ERROR" /> 
        <appender-ref ref="rolling-out" />
    </logger>


    <logger name="log4j.logger.org.mule">           
        <appender-ref ref="rolling-out" />
    </logger>

    <logger name="log4j.logger.org.mulesoft">           
        <appender-ref ref="rolling-out" />
    </logger>

    <logger name="log4j.logger.org.apache.cxf">     
        <appender-ref ref="rolling-out" />
    </logger>

    <logger name="log4j.logger.org.apache">     
        <appender-ref ref="rolling-out" />
    </logger>

    <logger name="log4j.logger.org.springframework.beans.factory">          
        <appender-ref ref="rolling-out" />
    </logger>

    <root>
        <level value="INFO" />
        <appender-ref ref="rolling-out" />      
        <appender-ref ref="CONSOLE" />
    </root> 

</log4j:configuration>

更改路径:-<param name="File" value="C:/Users/Logs.log" />根据您的要求.. 此路径是生成日志文件的位置

于 2014-09-14T09:26:01.687 回答