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 2013/11/18 08:01:52 UTC

svn commit: r1542924 - /sling/site/trunk/content/documentation/development/logging.mdtext

Author: chetanm
Date: Mon Nov 18 07:01:51 2013
New Revision: 1542924

URL: http://svn.apache.org/r1542924
Log:
SLING-3243 - Update the Slf4j API bundle to 1.7.5

Updating the docs and minor formatting changes

Modified:
    sling/site/trunk/content/documentation/development/logging.mdtext

Modified: sling/site/trunk/content/documentation/development/logging.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/development/logging.mdtext?rev=1542924&r1=1542923&r2=1542924&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/development/logging.mdtext (original)
+++ sling/site/trunk/content/documentation/development/logging.mdtext Mon Nov 18 07:01:51 2013
@@ -6,6 +6,8 @@ This document is for new 4.x release of 
 to older version.
 </div>
 
+[TOC]
+
 ## Introduction
 
 Logging in Sling is supported by the `org.apache.sling.commons.log` bundle, which is one of the first bundles installed
@@ -294,11 +296,10 @@ needs to be done. This features allows r
 1. Set framework property `org.apache.sling.commons.log.julenabled` to true
 2. Set the [LevelChangePropagator][8] in LogbackConfig
 
-    :::xml
-    <configuration>
-      <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
-      ...
-    </configuration>
+        :::xml
+        <configuration>
+          <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
+        </configuration>
 
 ### <a name="config-override"></a>Configuring OSGi based appenders in Logback Config
 
@@ -331,9 +332,60 @@ create an appender with name `logs/error
 In this case then Log module would create appender based on Logback config instead of OSGi config. This can
 be used to move the application from OSGi based config to Logback based config easily
 
-## WebConsole Plugin enhancements
+## Using Slf4j API 1.7
+
+With Slf4j API 1.7 onwards its possible to use logger methods with varargs i.e. log n arguments without 
+constructing an object array e.g. `log.info("This is a test {} , {}, {}, {}",1,2,3,4)`. Without var args
+you need to construct an object array `log.info("This is a test {} , {}, {}, {}",new Object[] {1,2,3,4})`. 
+To make use of this API and still be able to use your bundle on Sling system which package older version
+of API jar follow the steps below (See [SLING-3243][SLING-3243]) for more details
+
+1. Update the api version in pom dependency
+
+        :::xml
+        <dependencies>
+            <dependency>
+              <groupId>org.slf4j</groupId>
+              <artifactId>slf4j-api</artifactId>
+              <version>1.7.5</version>
+              <scope>provided</scope>
+            </dependency>
+           ...
+        </dependency>
+
+2. Add `Import-Package` instruction with custom version range. 
+
+        :::xml
+        <build>
+            <plugins>
+              <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                  <instructions>
+                    ...
+                    <Import-Package>
+                      org.slf4j;version="[1.5,2)",
+                      *
+                    </Import-Package>
+                  </instructions>
+                </configuration>
+              </plugin>
+              ...
+           </plugins>
+        </build>
+
+Above setup ensures following things
+
+1. Slf4j API bundle 1.7.x is binary compatible with 1.6.x.
+2. It allows bundle to make use of var args feature while making logging calls
+3. Bundle can still be deployed on older system which package 1.6.4 version of slf4j api
+
+
+## WebConsole Plugin
 
-The web Console Plugin supports following features
+The Web Console Plugin supports following features
 
 * Displays list of loggers which have level or appender configured
 * List of File appenders with location of current active files
@@ -349,4 +401,5 @@ The web Console Plugin supports followin
 [4]: http://logback.qos.ch/manual/configuration.html#fileInclusion
 [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
\ No newline at end of file
+[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