title: Logging in Eclipse/OSGi plugins
body: <p>I am starting to develop an Eclipse plugin (technically, an OSGi plugin) and one of the first problems I've run into is that I can't seem to control the commons-logging output as I normally would.</p>
  
  <p>I've included the commons-logging package in the plugin dependencies, and indeed, when I log something (at INFO or higher severity) it is logged to the console.  However, I can't seem to log at any lower level (such as DEBUG or TRACE).</p>
  
  <p>I have specified a log4j.properties file, and it is on the classpath (for the runtime, just as the commons-logging package is) but none of the settings in that properties file have any impact on the behavior of the logger.</p>
  
  <p>Here's the log4j.properties file:</p>
  
  <pre><code>#  Log4j Logging levels, in order of decreasing importance are:
  #   FATAL, ERROR, WARN, INFO, DEBUG, TRACE
  #
  
  # Root logger option
  log4j.rootLogger=ERROR,stdout
  #,LOGFILE
  
  # Direct log messages to stdout
  log4j.appender.stdout=org.apache.log4j.ConsoleAppender
  log4j.appender.stdout.Target=System.out
  log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
  log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %r (%l) %t%n - %m%n
  </code></pre>
  
  <p>What do I need to do so that I can actually control the output of the logger?</p>
  
  <p>Here are some sample output messages, in the hopes that the formatting may coincide with a default for java.util.logging, or provide other hints to someone:</p>
  
  <pre><code>Oct 21, 2008 11:01:23 PM com.stottlerhenke.sentinel.client.Activator start
  SEVERE: fatal_message
  Oct 21, 2008 11:01:23 PM com.stottlerhenke.sentinel.client.Activator start
  WARNING: warn_message
  Oct 21, 2008 11:01:23 PM com.stottlerhenke.sentinel.client.Activator start
  INFO: info_message
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>I have now tried various combinations of:</p>
  
  <ul>
  <li>org.osgi.service.log.LogService et al.</li>
  <li><a href="http://www.slf4j.org/" rel="noreferrer">slf4j</a></li>
  <li><a href="http://logging.apache.org/log4j/" rel="noreferrer">Log4J</a></li>
  <li><a href="http://commons.apache.org/logging/" rel="noreferrer">Commons-logging</a></li>
  <li><a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/logging/package-summary.html" rel="noreferrer">java.util.logging</a></li>
  </ul>
  
  <p>and I can <em>only</em> get DEBUG, or lower, level messages to appear if I am running OSGi manually from a prompt (which is impractical for what I am developing).  Furthermore, I can't effect any other type of logging configuration via various properties files.  Everything I try in that regard seems to be overridden by an eclipse setting.</p>
  
  <p>I've also tried putting various config files for the above libraries in numerous places, including as plug-in fragments attached to their respective libraries as suggested <a href="http://www.eclipsezone.com/eclipse/forums/t99588.html" rel="noreferrer">here</a>, and still, the same result happens.</p>
  
  <p>I've implemented a custom LogListener, and traced the entire path of a log message (as well as I know how, anyway) with System.out.println's, and debug messages <em>are</em> present right up until they are output by whatever underlying logging API I'm using, then they disappear.</p>