简体   繁体   中英

How to write Mule console output in a Text File

How to write a Mule Console Output to a text file. i am not able to see the full console output for big batch runs.

You need to add a log4j properties file into your main/resources directory, this log4j.xml file will do the trick

  <?xml version="1.0" encoding="UTF-8"?>  
  <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
  <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>

 <appender name="file-appender"
        class="org.apache.log4j.FileAppender">
<param name="file" value="path_to_your_log_file_here.log" />
<param name="append" value="true" />
<param name="threshold" value="debug" />
<layout class="org.apache.log4j.PatternLayout">
  <param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{1}] - %m%n" />
</layout>
</appender>

<root>
<level value="file-appender" />
<appender-ref ref="file-appender" />
</root>

</log4j:configuration>

What you see in the console should be already present on the log directory in two different files. One for the mule logs itself and another one for your app's log.

In case if we need to update the properties file directly (log4j.properties). below will serve the purpose.

log4j.rootLogger=INFO, default.out, default.file 

log4j.appender.default.out=org.apache.log4j.ConsoleAppender
log4j.appender.default.out.threshold=DEBUG
log4j.appender.default.out.layout=org.apache.log4j.PatternLayout
log4j.appender.default.out.layout.ConversionPattern=%-5p %c: %m%n

log4j.appender.default.file=org.apache.log4j.FileAppender
log4j.appender.default.file.append=true
log4j.appender.default.file.file=\\Desktop\\Mule.log
log4j.appender.default.file.threshold=INFO
log4j.appender.default.file.layout=org.apache.log4j.PatternLayout
log4j.appender.default.file.layout.ConversionPattern=%-5p %c: %m%n

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM