Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 716
Rian Schmits Avatar asked Aug 21 '15 11:08

Rian Schmits


People also ask

How do I check sling logs on AEM?

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.

What's the exact name of the bundle where you configure a custom sling log?

sling. commons. log : This bundle contains logback and allows to configure logback logging based on OSGi configurations or logback XML.

How do you change the log level in AEM?

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.


1 Answers

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.

like image 91
Rian Schmits Avatar answered Nov 01 '22 02:11

Rian Schmits