Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to change the log level? Adding a logManager config file results in duplicate log entries.

Avatar

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile
TB3dock
Level 4

25-05-2021

out of the box, all java code logs written to error.log are duplicated.

The culprit is having your own logger format:

/myapp.ui.config/src/main/content/jcr_root/apps/myapp/osgiconfig/config.author.local/org.apache.sling.commons.log.LogManager.factory.config~myapp.cfg.json

e.g.

 

 

{
  "org.apache.sling.commons.log.pattern": "{0,date,yyyy-MM-dd HH:mm:ss.SSS} {4} [{3}] {5}",
  "org.apache.sling.commons.log.names": [
    "com.myorg.myproj.aem"
  ],
  "org.apache.sling.commons.log.level": "debug",
  "org.apache.sling.commons.log.file": "logs/error.log",
  "org.apache.sling.commons.log.additiv": "true"
}

 

 

If you remove this file, you get one copy of each log line, but only for info, and with some default format we want to change.

So if adding our own logger config results in duplicate logs, how do we modify the existing one, which is not in any of the osgi config files in our source code?

We cant edit anything via the osgi manager web UI, as this would only change for one person, not everyone.

In addition, the json format for logs doesnt work with setting the MDC values in a filter. How do we get these into the logs?

            MDC.put("APPID", APPID);

            MDC.put(CORRELATION_HEADER, token);

 

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile
TB3dock
Level 4

25-05-2021

The solution for the duplicate entries was to change 

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

To

  "org.apache.sling.commons.log.additiv": "false"

 However have not found a solution to include the MDC vars yet.