Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: for the plan.

Jump to: navigation, search


Update Sites
Mailing List
Open Bugzilla tickets
Open Gerrit reviews
Browse Source
Continuous Integration

Migration to SLF4J logging

SWTBot 4.0.0 has removed its use of org.apache.log4j and is instead using the org.slf4j.api facade for its logging. Migration to SLF4J gives the flexibility of using any of the logger, e.g. simple, log4j, logback, etc.

The users of SWTBot have to include one of the SLF4J Binders to get log messages from SWTBot tests.

The following messages will appear after running the test, when there is no SLF4J Binding-

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation

At this point, you have to start using SLF4J Binder.

This section illustrates one set of combinations that are tested with Eclipse 2022-06. There can be various such combinations.

Note- The versions of slf4j binding jars may vary depending upon the Eclipse version. It is important to pick the jars compatible to your Eclipse version from Orbit downloads.

Do not include multiple loggers at the same time in your application.

For simplicity, lib folder in the examples below is the folder in the plugin that contains the jars that are required in classpath. You may use any mechanism to get them in classpath.

Simple Logger-

1. Install SLF4J Simple Binding from Orbit. It will install org.slf4j.binding.simple jar.


 Import-Package: org.slf4j
 Bundle-ClassPath: .,

3. Add at the root of the plugin.

4. Test code should define logger as:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SLF4JTest {
public static final Logger logger = LoggerFactory.getLogger(SLF4JTest.class); }

5. PDE SWTBot Run launch

Arguments tab can have level “-Dorg.slf4j.simpleLogger.defaultLogLevel=debug” if you want debug level messages.

Plugins tab- Include org.slf4j.binding.simple and org.slf4j.api along with other required plugins.

Log4j logger-

1. Install SLF4J log4j Binding and org.apache.log4j from Orbit. It will install org.slf4j.binding.log4j12 and org.apache.log4j jars. The versions of org.apache.log4j, log4j binder and slf4j should be compatible.

org.slf4j.impl.log4j12 is also one option that works with older versions of Eclipse.

Do not use multiple implementations and bridges of log4j; otherwise it will cause StackOverflow.


 Import-Package: org.slf4j
 Bundle-ClassPath: .,

3. Add at the root of the plugin. If you want to get debug messages in log, you need to set ‘threshold’ property of the Appender.

4. Define logger in your test code as above.

5. PDE SWTBot Run launch

Plugins tab- Include org.slf4j.binding.log4j12 , org.apache.log4j and org.slf4j.api along with other required plugins.

Logback logger-

1. Install Logback SLF4J Binding, Logback Classic Module and Core Module from Orbit. It will install ch.qos.logback.classic, ch.qos.logback.Core and ch.qos.logback.slf4j


 Require-Bundle: org.eclipse.swtbot.go,
 Import-Package: org.slf4j
 Bundle-ClassPath: .,

3. Define logger in your test code as above.

4. PDE SWTBot Run launch

Plugins tab- Include ch.qos.logback.classic, ch.qos.logback.core, ch.qos.logback.slf4j and org.slf4j.api along with other required plugins.

Enabling SLF4J logging in Maven/CI

To enable SLF4J logging from SWTBot using Maven or in CI environment, the following steps can be used:

1. Add slf4j.api and chosen binding in target, for example from Orbit:

 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.slf4j.api" version="0.0.0"/>
 <unit id="org.slf4j.binding.simple" version="0.0.0"/>
 <repository location=""/>

2. Add the binding plug-in matching the target as an extra requirement in the profile (you may want to use a profile that only applies for SWTBot test plug-ins) in the pom.xml:


3. To configure the chosen logger, a properties file might need to be used, e.g. or However this file is searched by slf4j by the class loader of the org.slf4j.api plug-in. In order to be found, this file should be included in a Fragment Project plug-in that has org.slf4j.api as a fragment host:

 Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: My Project SLF4J Binding Properties Fragment
 Bundle-Version: 1.0.0.qualifier
 Bundle-Vendor: My Vendor
 Fragment-Host: org.slf4j.api
 Bundle-RequiredExecutionEnvironment: JavaSE-11

4. Create the desired properties file in the root of this fragment plug-in, for example


5. Include the properties file in the of the fragment plug-in:

 bin.includes = META-INF/,\

6. Add the fragment plug-in as another extra dependency in the pom.xml, at the same level as the binding plug-in:


Back to the top