SLF4J Equinox
![Javadocs](https://camo.githubusercontent.com/e3c43c5747cf9dd877dc7362b6a4e686b006aa79e700c2a56732b30cc38ea4e8/68747470733a2f2f7777772e6a617661646f632e696f2f62616467652f636f6d2e6769746875622e6d6172736368616c6c2f636f6d2e6769746875622e6d6172736368616c6c2e736c66346a2d657175696e6f782e737667)
This is an implementation of SLF4J using the Equinox ExtendedLogService.
In plain words it makes all code that uses SLF4J and log to Equinox .metadata/.log
log file. It does this by redirecting all the log messages to the Equinox ExtendedLogService. This is mostly interesting for code that runs inside Eclipse RCP applications. This does not make Equinox use SLF4J.
The implementation uses the same techniques as the ch.qos.logback.slf4j
bundle.
Caveats
- the Equinox context object is always
null
- the SLF4J markers are ignored
This shouldn't be installed along side ch.qos.logback.slf4j
or org.slf4j.impl.log4j12
There's a p2 negation requirement taking care of this.
There are two SLF4J bundles the Maven artifact uses slf4j.api
the Orbit uses org.slf4j.api
.
Implementation Notes
We keep a ConcurrentHashMap
of strings to logger adapters. A ConcurrentHashMap
uses more memory than HashMap
but allows for concurrent lookups even though ExtendedLogServiceImpl#getLogger
is synchronized
. The values are not weak for now as Log4jLoggerFactory
doesn't use weak values as well.
Although Eclipse-GenericCapability
is deprecated using Provide-Capability
instead doesn't pass plugin validation in PDE.
Since a bundle can not have an activator we have to manually get a BundleContext
using FrameworkUtil
. However at this point the org.slf4j.api
bundle is only resolve so we need to manually start it.
Building
If you want to build this project then you need Maven 3 and add the following section to your settings.xml
<profile>
<id>photon</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<repositories>
<repository>
<id>photon</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/photon</url>
</repository>
</repositories>
</profile>
Publishing
To publish the artifact to a p2 site (or build a new one) you can use the Features And Bundles Publisher Application
java -jar <targetProductFolder>/plugins/org.eclipse.equinox.launcher_*.jar \
-application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher \
-metadataRepository file:/<some location>/repository \
-artifactRepository file:/<some location>/repository \
-source /<location with a plugins and features directory> \
-configs gtk.linux.x86 \
-compress \
-publishArtifacts
Installing
You can install form the site you built above using the p2 director application
java -jar <targetProductFolder>/plugins/org.eclipse.equinox.launcher_*.jar \
-application org.eclipse.equinox.p2.director \
-repository file:/<some location>/repository \
-installIU com.github.marschall.slf4j-equinox \
-uninstallIU org.slf4j.log4j,ch.qos.logback.slf4j,org.eclipse.jetty.slf4jlogback.feature.group,org.eclipse.jetty.sdk.feature.group \
-tag slf4j-equinox \
-destination <targetProductFolder>