0
votes

I have log4j config file, it seems to be working for normal flows, but when comes to batch it is not working, not sure what has to added in config file in specific to batch. Please help on this issue

<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>

Blog i have found like this log4j.logger.com.mulesoft.module.batch=INFO. I'm not sure what all the config specific for batch has to be added in above xml. Are we have any special config for Batch in Log4j Mule ESB? I'm not sure how to be executed for batch. Thanks in advance.

1

1 Answers

0
votes

Try the following in your 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>

Change the path :- <param name="File" value="C:/Users/Logs.log" /> according to your requirement .. This path is where the log file will be generated