[
https://issues.apache.org/jira/browse/SLING-3048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13761799#comment-13761799
]
Bertrand Delacretaz commented on SLING-3048:
--------------------------------------------
Thanks very much for your contribution, for now I have committed it under
https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/slf4j-mdc with
minor changes (minor typos), please cross-check.
Now, there are no automated tests ;-)
The simplest might be an integration test that activates this bundle,
configures some additional captures and verifies the resulting log. Maybe using
the Sling testing tools as in the SLING-2803 it-http module (Radu's second
patch from July 2nd) would be an easy way to do that.
> 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