Search code examples
javaosgilogbackequinoxsling

Sling logging configuration in Equinox


I am trying to use Apache Sling logging in an Equinox project. It is working fine, but I can't make Sling to use my config file. I am using a standard logback configuration xml, which should work according to the Sling documentation. But no matter where I put the configuration file Sling just doesn't use it.

My logback configuration is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    <!-- encoders are assigned the type
         ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
    <encoder>
      <pattern>%d{dd.MM.yyyy HH:mm:ss.SSS} *%level* [%thread] %logger %message%n</pattern>
    </encoder>
  </appender>

  <root level="debug">
    <appender-ref ref="CONSOLE" />
  </root>
</configuration>

Solution

  • The only way I managed to get Sling to use my config file is to pass the location of the configuration file as a VM argument like this: -Dorg.apache.sling.commons.log.configurationFile=/path/to/logbackconfigfile, where the path is the full path of configuration file location. Unfortunately I haven't managed to get it to work with a relative path.