You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ch...@apache.org on 2015/05/22 11:54:08 UTC

svn commit: r1681061 - in /sling/site/trunk/content/documentation: bundles/log-tracers.mdtext bundles/mdc-filter-config.png development/logging.mdtext

Author: chetanm
Date: Fri May 22 09:54:08 2015
New Revision: 1681061

URL: http://svn.apache.org/r1681061
Log:
Update the logging support related docs
- Refer to Tracer from logging doc
- Refer to Slf4j-MDC support and Groovy Fragment in logging docs

Added:
    sling/site/trunk/content/documentation/bundles/mdc-filter-config.png   (with props)
Modified:
    sling/site/trunk/content/documentation/bundles/log-tracers.mdtext
    sling/site/trunk/content/documentation/development/logging.mdtext

Modified: sling/site/trunk/content/documentation/bundles/log-tracers.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/bundles/log-tracers.mdtext?rev=1681061&r1=1681060&r2=1681061&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/bundles/log-tracers.mdtext (original)
+++ sling/site/trunk/content/documentation/bundles/log-tracers.mdtext Fri May 22 09:54:08 2015
@@ -153,7 +153,7 @@ This would result in following server si
 
 ## Installation
 
-Currently the bundle is not released and has to be build
+Currently the bundle is not released and has to be build from [here][6]
 
     ::xml
     <dependency>
@@ -168,4 +168,5 @@ Currently the bundle is not released and
 [3]: https://sling.apache.org/apidocs/sling5/org/apache/sling/api/request/RequestProgressTracker.html
 [4]: http://dev.day.com/content/ddc/blog/2008/06/requestprogresstracker.html
 [SLING-4739]: https://issues.apache.org/jira/browse/SLING-4739
-[5]: http://sling.apache.org/downloads.cgi
\ No newline at end of file
+[5]: http://sling.apache.org/downloads.cgi
+[6]: http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/tracer/
\ No newline at end of file

Added: sling/site/trunk/content/documentation/bundles/mdc-filter-config.png
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/bundles/mdc-filter-config.png?rev=1681061&view=auto
==============================================================================
Binary file - no diff available.

Propchange: sling/site/trunk/content/documentation/bundles/mdc-filter-config.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Modified: sling/site/trunk/content/documentation/development/logging.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/development/logging.mdtext?rev=1681061&r1=1681060&r2=1681061&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/development/logging.mdtext (original)
+++ sling/site/trunk/content/documentation/development/logging.mdtext Fri May 22 09:54:08 2015
@@ -373,6 +373,103 @@ The Slf4j API bundle 1.7.x is binary com
 This setup allows your bundles to make use of the var args feature while making logging calls, but the bundles
 can still be deployed on older systems which provide only the 1.6.4 version of the slf4j api.
 
+## Log Tracer
+
+Log Tracer provides support for enabling the logs for specific category at specific 
+level and only for specific request. It provides a very fine level of control via config provided
+as part of HTTP request around how the logging should be performed for given category.
+
+Refer to [Log Tracer Doc](/documentation/bundles/log-tracers.html) for more details
+
+## Slf4j MDC
+
+Sling MDC Inserting Filter exposes various request details as part of [MDC][11].
+ 
+Currently it exposes following variables:
+
+1. `req.remoteHost` - Request remote host
+2. `req.userAgent` - User Agent Header
+3. `req.requestURI` - Request URI
+4. `req.queryString` - Query String from request
+5. `req.requestURL` -
+6. `req.xForwardedFor` -
+7. `sling.userId` - UserID associated with the request. Obtained from ResourceResolver
+8. `jcr.sessionId` - Session ID of the JCR Session associated with current request.
+
+The filter also allow configuration to extract data from request cookie, header and parameters. 
+Look for configuration with name 'Apache Sling Logging MDC Inserting Filter' for details on 
+specifying header, cookie, param names.
+
+![MDC Filter Config](/documentation/bundles/mdc-filter-config.png)
+
+### Installation
+
+Download the bundle from [here][12] or use following Maven dependency
+
+    ::xml
+    <dependency>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>org.apache.sling.extensions.slf4j.mdc</artifactId>
+        <version>1.0.0</version>
+    </dependency>
+    
+## Logback Groovy Fragment
+
+This fragment is required to make use of Groovy based event evaluation support 
+provided by Logback. This enables programatic filtering of the log messages and
+is useful to get desired logs without flooding the system. For example Oak
+logs the JCR operations being performed via a particular session. if this lo is 
+enabled it would flood the log with messages from all the active session. However
+if you need logging only from session created in a particular thread then that 
+can be done in following way
+
+    ::xml
+    <?xml version="1.0" encoding="UTF-8"?>
+    <configuration scan="true" scanPeriod="1 second">
+      <jmxConfigurator/>
+      <newRule pattern="*/configuration/osgi" actionClass="org.apache.sling.commons.log.logback.OsgiAction"/>
+      <newRule pattern="*/configuration/appender-ref-osgi" actionClass="org.apache.sling.commons.log.logback.OsgiAppenderRefAction"/>
+      <osgi/>
+    
+       <appender name="OAK" class="ch.qos.logback.core.FileAppender">
+        <filter class="ch.qos.logback.core.filter.EvaluatorFilter">      
+          <evaluator class="ch.qos.logback.classic.boolex.GEventEvaluator"> 
+            <expression><![CDATA[
+                return e.getThreadName().contains("JobHandler");
+            ]]></expression>
+          </evaluator>
+          <OnMismatch>DENY</OnMismatch>
+          <OnMatch>ACCEPT</OnMatch>
+        </filter>
+        <file>${sling.home}/logs/oak.log</file>
+        <encoder>
+          <pattern>%d %-5level [%thread] %marker- %msg %n</pattern> 
+          <immediateFlush>true</immediateFlush>
+        </encoder>
+      </appender>
+    
+      <logger name="org.apache.jackrabbit.oak.jcr.operations" level="DEBUG" additivity="false">
+          <appender-ref ref="OAK"/>
+      </logger>
+    </configuration>
+    
+Logback exposes a variable `e` which is of type [ILoggingEvent][13]. It provides access to current logging
+event. Above logback config would route all log messages from `org.apache.jackrabbit.oak.jcr.operations`
+category to `${sling.home}/logs/oak.log`. Further only those log messages would be logged
+where the `threadName` contains `JobHandler`. Depending on the requirement the expression can
+be customised.
+
+### Installation
+
+Currently the bundle is not released and has to be build from [here][14]
+
+    ::xml
+    <dependency>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>org.apache.sling.extensions.logback-groovy-fragment</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+    </dependency>
+
 ## FAQ
 
 ##### Q. Can Sling Commons Log bundle be used in non Sling environments
@@ -414,4 +511,8 @@ The Web Console Plugin supports the foll
 [8]: http://logback.qos.ch/manual/configuration.html#LevelChangePropagator
 [9]: http://www.slf4j.org/api/org/slf4j/bridge/SLF4JBridgeHandler.html
 [10]: http://logback.qos.ch/manual/appenders.html#TimeBasedRollingPolicy
-[SLING-3243]: https://issues.apache.org/jira/browse/SLING-3243
\ No newline at end of file
+[SLING-3243]: https://issues.apache.org/jira/browse/SLING-3243
+[11]: http://www.slf4j.org/manual.html#mdc
+[12]: http://sling.apache.org/downloads.cgi
+[13]: http://logback.qos.ch/apidocs/ch/qos/logback/classic/spi/ILoggingEvent.html
+[14]: http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/logback-groovy-fragment/
\ No newline at end of file