Logging - GeoscienceAustralia/earthsci GitHub Wiki

The EarthSci platform provides an au.gov.ga.earthsci.logging plugin that configures SLF4J and overrides the default provided logging mechanisms.

This plugin replaces:

  1. The default Eclipse org.eclipse.e4.core.services.log.Logger implementation,
  2. The default Eclipse org.eclipse.e4.core.services.log.ILoggerProvider factory,
  3. The default OSGi org.osgi.service.log.LogService implementation, and
  4. Any existingjava.util.logging.* configuration

The plugin bridges these disparate logging mechanisms into a single SLF4J layer backed by the LogBack implementation.

As a developer, you are still able to use any of these logging mechanisms in your code as appropriate. However, if you are writing components that exist outside of the e4 dependency injection mechanism, or are not OSGi bundle specific, we recommend you use the industry standard SLF4J 'classic' logging approach.

Getting a logger

SLF4J 'classic' approach

This is the recommended approach to use for any code that is:

  • Outside the Eclipse dependency injection mechanism, or
  • Not specific to the lifecycle of an OSGi bundle, or
  • Needed within classes that are instantiated outside a bundle or Eclipse context
...
private static final Logger logger = LoggerFactory.getLogger(MyClass.class);
...

Changing logging behavior

Currently logging is provided by the LogBack framework. This is a highly flexible framework that offers configuration via XML.

The default configuration is provided by the au.gov.ga.earthsci.logging plugin. To change this behavior, simply place a logback.xml file into the workspace.

For more information on LogBack configuration, see the project documentation.

References

  1. SLF4J - http://www.slf4j.org/
  2. LogBack - http://logback.qos.ch/
  3. e4 platform services - http://www.vogella.com/articles/Eclipse4Services/article.html
  4. OSGi log service - http://www.osgi.org/javadoc/r4v42/org/osgi/service/log/LogService.html