Chetan Mehrotra created SLING-3048:
--------------------------------------

             Summary: Filter to populate SLF4J MDC with request details
                 Key: SLING-3048
                 URL: https://issues.apache.org/jira/browse/SLING-3048
             Project: Sling
          Issue Type: Improvement
          Components: Extensions
            Reporter: Chetan Mehrotra
         Attachments: org.apache.sling.extensions.mdc-0.0.1-SNAPSHOT-src.zip

With Commons Log moving to Logback its possible to use MDC [1] support of SLF4J 
in Sling to get better logs and also enable better filtering of logs. The patch 
adds a new extension module which registers a {{MDCInsertingFilter}}. This 
filter can extract information from incoming request and add them to the MDC

Features supported
1. By default expose details like Request path, Query String etc based on [3]
2. Exposes OSGi config where one can define what HTTP Header, Parameter or 
Cookie needs to be added to MDC
3. Exposes Session ID, USer Information from RequestResolver associated with 
current thread of execution

This information can then later be exposed via logs like shown below. Here we 
expose the SessionID as part of log

---
%d{dd.MM.yyyy HH:mm:ss.SSS} *%level* [%thread] %logger [%X{jcr.sessionId}] 
%msg%n
---

The same information can also be used to filter logs based on user,url etc or 
used in custom Logging event evaluator
For more details refer to [2]

[1] http://www.slf4j.org/manual.html#mdc
[2] https://github.com/chetanmeh/sling-logback/tree/master/mdc
[3] http://logback.qos.ch/manual/mdc.html#mis 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to