Two or more custom logs - AEM | Community
Skip to main content
Singaiah_Chintalapudi
Level 7
May 2, 2018

Two or more custom logs - AEM

  • May 2, 2018
  • 3 replies
  • 9384 views

Hi,

Currently, we have a custom log name (org.apache.sling.commons.log.LogManager.factory.config-customLog1): custom-log1.log and logging all the details for: com.gemotrixx.aem

I have created another logger (org.apache.sling.commons.log.LogManager.factory.config-customLog2) name is: custom-log2.log and logging com.geometrixx.aem.core.newfunctionality details.

When I run the new functionality, it should log details to both logs but its logging into only the second log.

I am getting the logger : Logger log = LoggerFactory.getLogger(getClass());

Can we get a specific logger instance to log the details as mentioned in below post?

Can you someone help me to understand this?

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

smacdonald2008
Level 10
May 2, 2018

For information about how logging works within AEM - see  -- Logging

Singaiah_Chintalapudi
Level 7
May 2, 2018

It did not explain about the multiple custom logs. This is a general documentation about configuring a custom log.

smacdonald2008
Level 10
May 2, 2018

I am seeing no AEM docs that suggests multiple logs can be used.

You can configure AEM to log to custom logs too -- see this community artilce - CQ Logs - CQ Tutorials 

or - Monitoring and Maintaining Your CQ instance

VeenaVikraman
Community Advisor
Community Advisor
May 2, 2018

No . I don't think that is correct. Since the core.newfunctionality is more precise the classes under that package will send logs to the log2. Others will be logged to log1.

Singaiah_Chintalapudi
Level 7
May 2, 2018

Thanks. Can you provide me some documentation to support the above conclusion? We want to log some pretty significantly important stuff and I want to make sure this is the right approach.

smacdonald2008
Level 10
May 2, 2018

As of now - there is no documentation on this use case.

joerghoh
Adobe Employee
Adobe Employee
May 2, 2018

The same log statements can go into 2 different logfiles. I just tested this in AEM 6.3 SP2, but it's likely there already for a while (although not really mentioned). The best way to find out if it's present is to to use the Sling Log console at localhost:4502/system/console/slinglog

When you create your logger via configuration, you have to set the "additiv" flag. For example I created a logfile for a caconfig related stuff. The definition in the JCR looks like this (.config notation):

org.apache.sling.commons.log.names=["org.apache.sling.caconfig"]

org.apache.sling.commons.log.file="logs/caconfig.log"

org.apache.sling.commons.log.level="trace"

org.apache.sling.commons.log.additiv="true"

Now when Sling CA-Config logs something it goes both into logs/caconfig.log and logs/error.log.

HTH,

Jörg

smacdonald2008
Level 10
May 2, 2018

We will capture Joerg's points too in the new community article. This is really what AEM community is all about - thanks Joerg!

smacdonald2008
Level 10
May 2, 2018

With Joergs response - i tested this too setting org.apache.sling.commons.log.additiv.

You can get AEM to log to the default log file (project-logsample) and a custom one (logsample-model.log).

However - still not seeing a way to write out a message to 2 custom log files bound to the same Java package. We will make that note in the article.