You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bu...@apache.org on 2015/05/22 11:54:18 UTC
svn commit: r952301 - in /websites/staging/sling/trunk/content: ./
documentation/bundles/log-tracers.html
documentation/bundles/mdc-filter-config.png
documentation/development/logging.html
Author: buildbot
Date: Fri May 22 09:54:18 2015
New Revision: 952301
Log:
Staging update by buildbot for sling
Added:
websites/staging/sling/trunk/content/documentation/bundles/mdc-filter-config.png (with props)
Modified:
websites/staging/sling/trunk/content/ (props changed)
websites/staging/sling/trunk/content/documentation/bundles/log-tracers.html
websites/staging/sling/trunk/content/documentation/development/logging.html
Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Fri May 22 09:54:18 2015
@@ -1 +1 @@
-1681057
+1681061
Modified: websites/staging/sling/trunk/content/documentation/bundles/log-tracers.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/bundles/log-tracers.html (original)
+++ websites/staging/sling/trunk/content/documentation/bundles/log-tracers.html Fri May 22 09:54:18 2015
@@ -229,7 +229,7 @@ and route them to normal logging on serv
<h2 id="installation">Installation</h2>
-<p>Currently the bundle is not released and has to be build</p>
+<p>Currently the bundle is not released and has to be build from <a href="http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/tracer/">here</a></p>
<div class="codehilite"><pre><span class="nt"><dependency></span>
<span class="nt"><groupId></span>org.apache.sling<span class="nt"></groupId></span>
<span class="nt"><artifactId></span>org.apache.sling.tracer<span class="nt"></artifactId></span>
@@ -237,7 +237,7 @@ and route them to normal logging on serv
<span class="nt"></dependency></span>
</pre></div>
<div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
- Rev. 1681057 by chetanm on Fri, 22 May 2015 09:36:56 +0000
+ Rev. 1681061 by chetanm on Fri, 22 May 2015 09:54:08 +0000
</div>
<div class="trademarkFooter">
Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project
Added: websites/staging/sling/trunk/content/documentation/bundles/mdc-filter-config.png
==============================================================================
Binary file - no diff available.
Propchange: websites/staging/sling/trunk/content/documentation/bundles/mdc-filter-config.png
------------------------------------------------------------------------------
svn:mime-type = image/png
Modified: websites/staging/sling/trunk/content/documentation/development/logging.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/development/logging.html (original)
+++ websites/staging/sling/trunk/content/documentation/development/logging.html Fri May 22 09:54:18 2015
@@ -122,10 +122,19 @@ This document is for the new (November 2
</li>
<li><a href="#external-config-file">External Config File</a></li>
<li><a href="#java-util-logging-jul-integration">Java Util Logging (JUL) Integration</a></li>
-<li><a href="#wzxhzdk13wzxhzdk14configuring-osgi-appenders-in-the-logback-config"><a name="config-override"></a>Configuring OSGi appenders in the Logback Config</a></li>
+<li><a href="#wzxhzdk16wzxhzdk17configuring-osgi-appenders-in-the-logback-config"><a name="config-override"></a>Configuring OSGi appenders in the Logback Config</a></li>
</ul>
</li>
<li><a href="#using-slf4j-api-17">Using Slf4j API 1.7</a></li>
+<li><a href="#log-tracer">Log Tracer</a></li>
+<li><a href="#slf4j-mdc">Slf4j MDC</a><ul>
+<li><a href="#installation">Installation</a></li>
+</ul>
+</li>
+<li><a href="#logback-groovy-fragment">Logback Groovy Fragment</a><ul>
+<li><a href="#installation_1">Installation</a></li>
+</ul>
+</li>
<li><a href="#faq">FAQ</a><ul>
<li><a href="#q-can-sling-commons-log-bundle-be-used-in-non-sling-environments">Q. Can Sling Commons Log bundle be used in non Sling environments</a></li>
<li><a href="#q-how-to-start-sling-with-an-external-logbackxml-file">Q. How to start Sling with an external logback.xml file</a></li>
@@ -197,7 +206,7 @@ following features:</p>
<tr>
<td><code>org.apache.sling.commons.log.packagingDataEnabled</code></td>
<td>true</td>
-<td>Boolean property to control packaging data support of Logback. See [Packaging Data][11] section of Logback for more details</td>
+<td>Boolean property to control packaging data support of Logback. See <a href="http://www.slf4j.org/manual.html#mdc">Packaging Data</a> section of Logback for more details</td>
</tr>
</tbody>
</table>
@@ -495,7 +504,7 @@ This allows for routing logging messages
</ol>
<p>If <code>org.apache.sling.commons.log.julenabled</code> is found to be true then <a href="http://logback.qos.ch/manual/configuration.html#LevelChangePropagator">LevelChangePropagator</a> would be
registered automatically with Logback </p>
-<h3 id="wzxhzdk13wzxhzdk14configuring-osgi-appenders-in-the-logback-config"><a name="config-override"></a>Configuring OSGi appenders in the Logback Config</h3>
+<h3 id="wzxhzdk16wzxhzdk17configuring-osgi-appenders-in-the-logback-config"><a name="config-override"></a>Configuring OSGi appenders in the Logback Config</h3>
<p>So far Sling used to configure the appenders based on OSGi config. This provides a very limited
set of configuration options. To make use of other Logback features you can override the OSGi config
from within the Logback config file. OSGi config based appenders are named based on the file name.</p>
@@ -573,6 +582,92 @@ of the API jar, follow the below steps.
<p>The Slf4j API bundle 1.7.x is binary compatible with 1.6.x.</p>
<p>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.</p>
+<h2 id="log-tracer">Log Tracer</h2>
+<p>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.</p>
+<p>Refer to <a href="/documentation/bundles/log-tracers.html">Log Tracer Doc</a> for more details</p>
+<h2 id="slf4j-mdc">Slf4j MDC</h2>
+<p>Sling MDC Inserting Filter exposes various request details as part of <a href="http://www.slf4j.org/manual.html#mdc">MDC</a>.</p>
+<p>Currently it exposes following variables:</p>
+<ol>
+<li><code>req.remoteHost</code> - Request remote host</li>
+<li><code>req.userAgent</code> - User Agent Header</li>
+<li><code>req.requestURI</code> - Request URI</li>
+<li><code>req.queryString</code> - Query String from request</li>
+<li><code>req.requestURL</code> -</li>
+<li><code>req.xForwardedFor</code> -</li>
+<li><code>sling.userId</code> - UserID associated with the request. Obtained from ResourceResolver</li>
+<li><code>jcr.sessionId</code> - Session ID of the JCR Session associated with current request.</li>
+</ol>
+<p>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.</p>
+<p><img alt="MDC Filter Config" src="/documentation/bundles/mdc-filter-config.png" /></p>
+<h3 id="installation">Installation</h3>
+<p>Download the bundle from <a href="http://sling.apache.org/downloads.cgi">here</a> or use following Maven dependency</p>
+<div class="codehilite"><pre><span class="nt"><dependency></span>
+ <span class="nt"><groupId></span>org.apache.sling<span class="nt"></groupId></span>
+ <span class="nt"><artifactId></span>org.apache.sling.extensions.slf4j.mdc<span class="nt"></artifactId></span>
+ <span class="nt"><version></span>1.0.0<span class="nt"></version></span>
+<span class="nt"></dependency></span>
+</pre></div>
+
+
+<h2 id="logback-groovy-fragment">Logback Groovy Fragment</h2>
+<p>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</p>
+<div class="codehilite"><pre><span class="cp"><?xml version="1.0" encoding="UTF-8"?></span>
+<span class="nt"><configuration</span> <span class="na">scan=</span><span class="s">"true"</span> <span class="na">scanPeriod=</span><span class="s">"1 second"</span><span class="nt">></span>
+ <span class="nt"><jmxConfigurator/></span>
+ <span class="nt"><newRule</span> <span class="na">pattern=</span><span class="s">"*/configuration/osgi"</span> <span class="na">actionClass=</span><span class="s">"org.apache.sling.commons.log.logback.OsgiAction"</span><span class="nt">/></span>
+ <span class="nt"><newRule</span> <span class="na">pattern=</span><span class="s">"*/configuration/appender-ref-osgi"</span> <span class="na">actionClass=</span><span class="s">"org.apache.sling.commons.log.logback.OsgiAppenderRefAction"</span><span class="nt">/></span>
+ <span class="nt"><osgi/></span>
+
+ <span class="nt"><appender</span> <span class="na">name=</span><span class="s">"OAK"</span> <span class="na">class=</span><span class="s">"ch.qos.logback.core.FileAppender"</span><span class="nt">></span>
+ <span class="nt"><filter</span> <span class="na">class=</span><span class="s">"ch.qos.logback.core.filter.EvaluatorFilter"</span><span class="nt">></span>
+ <span class="nt"><evaluator</span> <span class="na">class=</span><span class="s">"ch.qos.logback.classic.boolex.GEventEvaluator"</span><span class="nt">></span>
+ <span class="nt"><expression></span><span class="cp"><![CDATA[</span>
+<span class="cp"> return e.getThreadName().contains("JobHandler");</span>
+<span class="cp"> ]]></span><span class="nt"></expression></span>
+ <span class="nt"></evaluator></span>
+ <span class="nt"><OnMismatch></span>DENY<span class="nt"></OnMismatch></span>
+ <span class="nt"><OnMatch></span>ACCEPT<span class="nt"></OnMatch></span>
+ <span class="nt"></filter></span>
+ <span class="nt"><file></span>${sling.home}/logs/oak.log<span class="nt"></file></span>
+ <span class="nt"><encoder></span>
+ <span class="nt"><pattern></span>%d %-5level [%thread] %marker- %msg %n<span class="nt"></pattern></span>
+ <span class="nt"><immediateFlush></span>true<span class="nt"></immediateFlush></span>
+ <span class="nt"></encoder></span>
+ <span class="nt"></appender></span>
+
+ <span class="nt"><logger</span> <span class="na">name=</span><span class="s">"org.apache.jackrabbit.oak.jcr.operations"</span> <span class="na">level=</span><span class="s">"DEBUG"</span> <span class="na">additivity=</span><span class="s">"false"</span><span class="nt">></span>
+ <span class="nt"><appender-ref</span> <span class="na">ref=</span><span class="s">"OAK"</span><span class="nt">/></span>
+ <span class="nt"></logger></span>
+<span class="nt"></configuration></span>
+</pre></div>
+
+
+<p>Logback exposes a variable <code>e</code> which is of type <a href="http://logback.qos.ch/apidocs/ch/qos/logback/classic/spi/ILoggingEvent.html">ILoggingEvent</a>. It provides access to current logging
+event. Above logback config would route all log messages from <code>org.apache.jackrabbit.oak.jcr.operations</code>
+category to <code>${sling.home}/logs/oak.log</code>. Further only those log messages would be logged
+where the <code>threadName</code> contains <code>JobHandler</code>. Depending on the requirement the expression can
+be customised.</p>
+<h3 id="installation_1">Installation</h3>
+<p>Currently the bundle is not released and has to be build from <a href="http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/logback-groovy-fragment/">here</a></p>
+<div class="codehilite"><pre><span class="nt"><dependency></span>
+ <span class="nt"><groupId></span>org.apache.sling<span class="nt"></groupId></span>
+ <span class="nt"><artifactId></span>org.apache.sling.extensions.logback-groovy-fragment<span class="nt"></artifactId></span>
+ <span class="nt"><version></span>1.0.0-SNAPSHOT<span class="nt"></version></span>
+<span class="nt"></dependency></span>
+</pre></div>
+
+
<h2 id="faq">FAQ</h2>
<h5 id="q-can-sling-commons-log-bundle-be-used-in-non-sling-environments">Q. Can Sling Commons Log bundle be used in non Sling environments</h5>
<p>This bundle does not depend on any other Sling bundle and can be easily used in any OSGi framework.
@@ -603,7 +698,7 @@ To get complete log support working you
</ul>
<p><img src="sling-log-support.png" /></p>
<div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
- Rev. 1575196 by chetanm on Fri, 7 Mar 2014 06:56:16 +0000
+ Rev. 1681061 by chetanm on Fri, 22 May 2015 09:54:08 +0000
</div>
<div class="trademarkFooter">
Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project