Logback doesn't print any log in Weblogic 12c

2.4k Views Asked by At

I want to move to Logback from java.util.logging.Logger. First I use this in my dependency.jar file. MyApp.ear is still use java logger.

Below is logback.xml.

<configuration>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <!-- encoders are assigned the type
     ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
    <encoder>
      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n  
      </pattern>
    </encoder>
  </appender>
  <root level="WARN">          
     <appender-ref ref="STDOUT" />
  </root>  
</configuration>

I added below depended jar files to my ant build file.

  <pathelement location="${global.lib}/slf4j-api-1.6.4.jar"/>
  <pathelement location="${global.lib}/logback-classic-1.0.1.jar"/>

I use weblogic 12C. Now my log level is WARN. But still the INFO logs are printing. Which means it still uses java logger. I suspect the dependent.jar logback log is overwritten by java logger in MyApp.ear.

I am not sure is there any place to modify in the weblogic 12Cto enable it.

logback.xml is available inside the dependency.jar.

1

There are 1 best solutions below

0
On BEST ANSWER

I added below jar path to my build.xml

<pathelement location="${global.lib}/logback/logback-core-1.0.10.jar"/>

Additionally I added below code to my weblogic-application.xml.

<wls:prefer-application-packages>
    <wls:package-name>org.slf4j.*</wls:package-name>
</wls:prefer-application-packages>
<wls:prefer-application-resources>
    <wls:resource-name>org/slf4j/impl/StaticLoggerBinder.class</wls:resource-name>
</wls:prefer-application-resources>

This resolved my issue.