0

I installed this bundle to CQ5.6.1

<dependency>
    <groupId>org.apache.sling</groupId>
    <artifactId>org.apache.sling.commons.log</artifactId>
    <version>4.0.0</version>
</dependency>

It works good, I have problem only with the additivity flag.

If I add a Apache Sling Logging Logger Configuration (org.apache.sling.commons.log.LogManager.factory) for a specific package, it won't be additive so it doesn't inherit the configuration from the parent loggers.

I'm using an external logback.xml.

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
  <jmxConfigurator/>
  <newRule pattern="*/configuration/osgi" actionClass="org.apache.sling.commons.log.logback.OsgiAction"/>
  <newRule pattern="*/configuration/appender-ref-osgi" actionClass="org.apache.sling.commons.log.logback.OsgiAppenderRefAction"/>
  <osgi/>

   <appender name="syslog" class="net.logstash.logback.appender.LogstashSocketAppender">
        <host>HOST</host>
        <port>PORT</port>
    </appender>

   <logger name="com.my.package" level="INFO"/>

   <root level="WARN">
     <appender-ref ref="syslog" />
   </root>    
</configuration>

I also have an OSGi config:

org.apache.sling.commons.log.file="logs/other.log"
org.apache.sling.commons.log.level="debug"
org.apache.sling.commons.log.file.size="'.'yyyy-MM-dd"
org.apache.sling.commons.log.file.number=I"7"
org.apache.sling.commons.log.pattern="{0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* [{2}] {3} {5}"
org.apache.sling.commons.log.names="com.my.package.other"

But logs from com.my.package.other never goes to the syslog.

If I add this line to my logback.xml:

<logger name="com.my.package.other" level="INFO"/>

Then on /system/console/slinglog I can see that the logger com.my.package.other is not additive.

So How can I use logs configured by org.apache.sling.commons.log.LogManager.factory as additive loggers?

Thanks in advance!

nerd
  • 837
  • 6
  • 21

2 Answers2

0

Using this hidden property solves the problem: https://github.com/apache/sling/blob/43528d39840cdf011dea5b2768686cc96ee3326e/bundles/commons/log/src/main/java/org/apache/sling/commons/log/logback/internal/LogConfigManager.java#L71

Unfortunately it cannot be configured on OSGi console (no field), so I have to configure it on osgi:config node.

nerd
  • 837
  • 6
  • 21
0

"Unfortunately it cannot be configured on OSGi console (no field)."

You cannot set hidden properties via the Felix console. But they can be set using sling:OsgiConfig nodes (http://sling.apache.org/site/jcr-installer-provider.html)

  • I know it. That's the way I configured loggers to be additive, though I don't like this. Anyone can add a new logger config on the osgi console, which could break logback logging... – nerd Oct 23 '14 at 10:12