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

Sl4j MDC log not printed

Avatar

Avatar
Validate 1
Level 1
sanketd11661823
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
sanketd11661823
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
sanketd11661823
Level 1

23-05-2018

Hi ,

I am trying configure SL4J MDC log but the logger is not printing in pattern given in the logger configuration .

Bellow are the steps followed.

1. created one logger configuration as shown in attached diagram with pattern  "%d{dd.MM.yyyy HH:mm:ss.SSS} *%p* [%X{req.q}] [%t] %c %msg%n".

2. In the Apache sling logging configuration added the parameter as "q".

3. In the Servlet put one logger.debug to print the logger.

4. We are hitting the Servlet with parameter q="something". Logger.debug not printing in the mdc log format ,even if we are removing time stampmdcfilter.jpgslingloggerconfig.jpg from the pattern it is always printing in the same format as

23.05.2018 16:24:54.581 *DEBUG* [0:0:0:0:0:0:0:1 [1527072894580] GET /bin/cookie/set HTTP/1.1] com.mattel.ag.core.servlets.CookieAddingServlet Querry parameter is q=Sinha1

Can any one please tell any configuration is missing or needed something else?

Replies

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

23-05-2018

Logging in AEM is discussed in this doc topic - Logging

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,081 likes

Total Posts

3,121 posts

Correct Reply

1,061 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,081 likes

Total Posts

3,121 posts

Correct Reply

1,061 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

23-05-2018

It's not nicely documented, but you need to install the Sling MDC Inserting Filter, available at these coordinates:

<dependency>

    <groupId>org.apache.sling</groupId>

    <artifactId>org.apache.sling.extensions.slf4j.mdc</artifactId>

    <type>zip</type>

    <version>1.0.0</version>

</dependency>

Deploying that bundle into AEM should do make it work.

regards,

Jörg

Avatar

Avatar
Validate 1
Level 1
sanketd11661823
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
sanketd11661823
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
sanketd11661823
Level 1

24-05-2018

Hi All,

Still am not getting slf4j-mdc log.Any suggestion for integration.

Avatar

Avatar
Validate 25
MVP
PuzanovsP
MVP

Likes

132 likes

Total Posts

540 posts

Correct Reply

164 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 10
View profile

Avatar
Validate 25
MVP
PuzanovsP
MVP

Likes

132 likes

Total Posts

540 posts

Correct Reply

164 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 10
View profile
PuzanovsP
MVP

24-05-2018

Dear Sanket,

Install mdc extension to your AEM instance.

Regards,Peter

Avatar

Avatar
Validate 1
Level 1
sanketd11661823
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
sanketd11661823
Level 1

Likes

0 likes

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
sanketd11661823
Level 1

24-05-2018

Hi PuzanovsP,

I Installed mdc extension to my AEM instance. I have created servlet to get SlingHttpServletRequest.

I created l ogs/mdcerror.log file with

"%d{dd.MM.yyyy HH:mm:ss.SSS} *%p* [%X{req.remoteHost}] [%t] %c %msg%n"  pattern.

Avatar

Avatar
Give Back 3
Level 3
SameerBhalerao
Level 3

Likes

25 likes

Total Posts

24 posts

Correct Reply

13 solutions
Top badges earned
Give Back 3
Give Back
Boost 5
Boost 3
Boost 25
View profile

Avatar
Give Back 3
Level 3
SameerBhalerao
Level 3

Likes

25 likes

Total Posts

24 posts

Correct Reply

13 solutions
Top badges earned
Give Back 3
Give Back
Boost 5
Boost 3
Boost 25
View profile
SameerBhalerao
Level 3

27-09-2019

A bit late reply but found out during my own debug session.

You need to set up the filter ranking higher. You can do it using either osgi repository based configuration or setup your own mdc filter. This happens when mdc filter is not called up in the hierarchy of filters so setup it's ranking high enough.

This resolved problem for me and my mdc pattern logs started firing up