Sl4j MDC log not printed | Community
Skip to main content
Level 2
May 23, 2018

Sl4j MDC log not printed

  • May 23, 2018
  • 3 replies
  • 4785 views

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 stamp 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?

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 23, 2018

Logging in AEM is discussed in this doc topic - Logging

joerghoh
Adobe Employee
Adobe Employee
May 23, 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

Level 2
May 24, 2018

Hi All,

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

Peter_Puzanovs
Community Advisor
Community Advisor
May 24, 2018

Dear Sanket,

Install mdc extension to your AEM instance.

Regards,Peter

Adobe Employee
September 27, 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