FELIX-2314: Improve logging support

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@939711 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/assembly/pom.xml b/karaf/assembly/pom.xml
index a5c6e91..b26ab29 100644
--- a/karaf/assembly/pom.xml
+++ b/karaf/assembly/pom.xml
@@ -53,6 +53,10 @@
         </dependency>
         <dependency>
             <groupId>org.apache.felix.karaf</groupId>
+            <artifactId>org.apache.felix.karaf.exception</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix.karaf</groupId>
             <artifactId>org.apache.felix.karaf.client</artifactId>
         </dependency>
         <dependency>
diff --git a/karaf/assembly/src/main/descriptors/unix-bin.xml b/karaf/assembly/src/main/descriptors/unix-bin.xml
index d148c48..35b2d63 100644
--- a/karaf/assembly/src/main/descriptors/unix-bin.xml
+++ b/karaf/assembly/src/main/descriptors/unix-bin.xml
@@ -128,6 +128,14 @@
     </files>
 
     <dependencySets>
+        <dependencySet>
+            <outputDirectory>/lib/endorsed</outputDirectory>
+            <unpack>false</unpack>
+            <useProjectArtifact>false</useProjectArtifact>
+            <includes>
+                <include>org.apache.felix.karaf:org.apache.felix.karaf.exception</include>
+            </includes>
+        </dependencySet>
 
         <dependencySet>
             <outputDirectory>/system</outputDirectory>
diff --git a/karaf/assembly/src/main/descriptors/windows-bin.xml b/karaf/assembly/src/main/descriptors/windows-bin.xml
index 995eed1..6e5a5f2 100644
--- a/karaf/assembly/src/main/descriptors/windows-bin.xml
+++ b/karaf/assembly/src/main/descriptors/windows-bin.xml
@@ -120,6 +120,14 @@
     </files>
 
     <dependencySets>
+        <dependencySet>
+            <outputDirectory>/lib/endorsed</outputDirectory>
+            <unpack>false</unpack>
+            <useProjectArtifact>false</useProjectArtifact>
+            <includes>
+                <include>org.apache.felix.karaf:org.apache.felix.karaf.exception</include>
+            </includes>
+        </dependencySet>
 
         <dependencySet>
             <outputDirectory>/system</outputDirectory>
diff --git a/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.logging.cfg b/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.logging.cfg
index 95bb4c2..7c1f73d 100644
--- a/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.logging.cfg
+++ b/karaf/assembly/src/main/distribution/text/etc/org.ops4j.pax.logging.cfg
@@ -19,15 +19,27 @@
 
 # Root logger
 log4j.rootLogger=INFO, out, osgi:VmLogAppender
+log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer
 
 # CONSOLE appender not used by default
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
 
 # File appender
 log4j.appender.out=org.apache.log4j.FileAppender
 log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
+log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
 log4j.appender.out.file=${karaf.base}/data/log/karaf.log
 log4j.appender.out.append=true
+
+# Sift appender
+log4j.appender.sift=org.apache.log4j.sift.MDCSiftingAppender
+log4j.appender.sift.key=bundle.name
+log4j.appender.sift.default=karaf
+log4j.appender.sift.appender=org.apache.log4j.FileAppender
+log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout
+log4j.appender.sift.appender.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
+log4j.appender.sift.appender.file=${karaf.base}/data/log/$\\{bundle.name\\}.log
+log4j.appender.sift.appender.append=true
+