title: logback via slf4j as separate osgi bundle
body: <p>We have <code>osgi</code> application in <code>karaf</code> and want to have logging properties inside bundle jar to keep the logging config in sources (currently they are in <code>karaf/etc/org.ops4j.pax.logging.cfg</code>)</p>
  
  <p>UPDATE: in fact now we keep log configs in Karaf CM Admin service, and it's a problem because on each release we should write special instructions to our operation team to make any tiny logging change. Moreover we have multiple karaf nodes (~10) and repeating these actions for each is a complex and error-prone task. Sure we can intall <code>Cellar</code> to each karaf node but it will complicate the osgi env and require some support for it, so the simplest way just to keep config in the sources</p>
  
  <p>I've googled that <a href="http://blog.kornr.net/index.php/2008/12/18/osgi-logging-putting-it-all-together#c115" rel="nofollow">easiest way to create a separate bundle</a> with does actual logging stuff with all dependencies (logback, slf4j, config) inside and just export <code>org.slf4</code> from them.</p>
  
  <p>I tried with this <code>pom.xml</code>:</p>
  
  <pre><code>&lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
              &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;unpackBundle&gt;true&lt;/unpackBundle&gt;
                  &lt;instructions&gt;
                      &lt;Embed-Dependency&gt;*;groupId=!junit|org.springframework|log4j|javax.jms|javax.mail&lt;/Embed-Dependency&gt;
                      &lt;Embed-Transitive&gt;false&lt;/Embed-Transitive&gt;
                      &lt;Embed-Directory&gt;target/dependency&lt;/Embed-Directory&gt;
                      &lt;Embed-StripGroup&gt;true&lt;/Embed-StripGroup&gt;
                      &lt;Export-Package&gt;org.slf4j&lt;/Export-Package&gt;
                      &lt;Import-Package&gt;
                          *
                      &lt;/Import-Package&gt;
                  &lt;/instructions&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;copy-dependencies&lt;/id&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;copy-dependencies&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;excludeGroupIds&gt;junit,org.springframework,log4j&lt;/excludeGroupIds&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
          &lt;version&gt;${slf4j.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
          &lt;artifactId&gt;com.springsource.ch.qos.logback.classic&lt;/artifactId&gt;
          &lt;version&gt;0.9.15&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
          &lt;artifactId&gt;com.springsource.ch.qos.logback.core&lt;/artifactId&gt;
          &lt;version&gt;0.9.15&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>but it puts to bundle manifest a lot of additional dependecies like <code>javax.mail/jms</code> etc:</p>
  
  <pre><code>Import-Package: javax.jms,javax.mail,javax.mail.internet,javax.management,javax.naming,javax.servlet,javax.servlet.http,javax.sql,javax.xml.parsers,org.codehaus.janino,org.slf4j;version="1.6",org.xml.sax,org.xml.sax.helpers,sun.reflect
  </code></pre>
  
  <p>sure it's not a good approach to deploy all this unnecessary stuff to karaf in order to resolve them.</p>
  
  <p>What's wrong or how to build a single bundle with all logging dependencies inside?</p>