3
votes

has anyone been able to use logback for their application deployed in Mule. I have got a file appender configured and got logback.xml in my classpath. However this doesn't seem to get picked up.

Kindly note Mule is stil probably using it's own default log4j implementation as I see mule.log does get some logging though not the ones I am attempting to log - which makes me feel my explicit log events are getting lost alltogether. Mule by default uses log4j but guess we can override that? Some documentation here but not too helpful http://www.mulesoft.org/documentation-3.2/display/MULE3USER/Configuring+Logging

What I want is use Logback just for my application without making changes to Mule System level jars and config.

FYI; I am trying to use the following in logback.xml

 <appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <file>D:\logs\mule\myauto.log</file>
        <encoder>
              <pattern>%d [%p] <%c> %m%n</pattern>
        </encoder>
  </appender>

  <appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
        <appender-ref ref="FILE" />
  </appender>

  <logger name="automationlogger" level="INFO">

        <appender-ref ref="asyncFileAppender" />
  </logger>
3

3 Answers

1
votes

The per-app logging is hardcoded to slf4j/log4j as mule-module-logging overrides some slf4j classes that the mule team had to change in order to make it work.

If you take a look at the mule-module-logging pom you can see what classes are shaded and why this won't allow you to use logback unless hacking directly the mule code.

1
votes

I have tried to replace the log4j jar files with logback and didn't work. The wrapper uses the log4j for logging and hence u need to have log4j jars in /lib/boot dir. If I add logback jars with out removing the log4j jars u get below warnings ..

SLF4J: Found binding in [jar:file:/C:/dev/mule-standalone-3.3.1/lib/boot/logback-classic-1.0.9.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/C:/dev/mule-standalone-3.3.1/lib/boot/mule-module-logging-3.3.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]

Now to remove mule logging module and add jcl-over-slf4j. Server starts and picks up logback.xml in config folder. But the mule application specific logging is gone.

End of the day, this is what I have done.

Remove : mule-module-logging-3.3.1

Add : logback-classic-1.0.9, logback-core-1.0.9, jcl-over-slf4j-1.7.2, log4j-over-slf4j-1.7.2

0
votes

I am not familiar with mule, but you can always use slf4j + logback, this would enable you to redirect logging calls made to log4j with the help of slf4j's log4j bridge.