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>
There are two ways to see the log files in AEM.Go to the felix console ->Sling->Log Support, and search for your log file. You can directly open the log file from here. 2. The logs files also gets created under crx-quickstart/logs.
sling. commons. log : This bundle contains logback and allows to configure logback logging based on OSGi configurations or logback XML.
Search for "Apache Sling Logging Logger Configuration" and click on "+" to add new configuration. Provide the package name in the Logger and Save the configuration. To change the logger level open the configured Logger from the "Apache Sling Logging Logger Configuration" and change log level. Save the configuration.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With