Bug 533396 - Replace LogService with org.osgi.service.log.Logger

Change-Id: I040de72a4b6b07b89232686594af64b0716da1c5
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
diff --git a/bundles/org.eclipse.e4.core.di.extensions.supplier/OSGI-INF/org.eclipse.e4.core.di.internal.extensions.ServiceSupplier.xml b/bundles/org.eclipse.e4.core.di.extensions.supplier/OSGI-INF/org.eclipse.e4.core.di.internal.extensions.ServiceSupplier.xml
index 23b8d7f..f64f106 100644
--- a/bundles/org.eclipse.e4.core.di.extensions.supplier/OSGI-INF/org.eclipse.e4.core.di.internal.extensions.ServiceSupplier.xml
+++ b/bundles/org.eclipse.e4.core.di.extensions.supplier/OSGI-INF/org.eclipse.e4.core.di.internal.extensions.ServiceSupplier.xml
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.eclipse.e4.core.di.internal.extensions.ServiceSupplier">
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.e4.core.di.internal.extensions.ServiceSupplier">
    <property name="dependency.injection.annotation" type="String" value="org.eclipse.e4.core.di.extensions.Service"/>
    <property name="event.topics" value="org/eclipse/e4/core/contexts/IEclipseContext/DISPOSE"/>
    <service>
       <provide interface="org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier"/>
       <provide interface="org.osgi.service.event.EventHandler"/>
    </service>
-   <reference cardinality="0..1" field="logService" interface="org.osgi.service.log.LogService" name="logService" policy="dynamic"/>
+   <reference bind="setLogger" cardinality="0..1" interface="org.osgi.service.log.LoggerFactory" name="Logger" policy="dynamic" unbind="unsetLogger"/>
    <implementation class="org.eclipse.e4.core.di.internal.extensions.ServiceSupplier"/>
 </scr:component>
\ No newline at end of file
diff --git a/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/ServiceSupplier.java b/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/ServiceSupplier.java
index 3bb4f61..dba6e31 100644
--- a/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/ServiceSupplier.java
+++ b/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/ServiceSupplier.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2014, 2017 BestSolution.at and others.
+ * Copyright (c) 2014, 2018 BestSolution.at and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -40,9 +40,11 @@
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Reference;
 import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
 import org.osgi.service.event.Event;
 import org.osgi.service.event.EventHandler;
-import org.osgi.service.log.LogService;
+import org.osgi.service.log.Logger;
+import org.osgi.service.log.LoggerFactory;
 
 /**
  * Supplier for {@link Service}
@@ -52,8 +54,8 @@
 		"event.topics=" + IEclipseContext.TOPIC_DISPOSE })
 public class ServiceSupplier extends ExtendedObjectSupplier implements EventHandler {
 
-	@Reference(cardinality = ReferenceCardinality.OPTIONAL)
-	volatile LogService logService;
+	LoggerFactory factory;
+	Logger logger;
 
 	static class ServiceHandler implements ServiceListener {
 		private final ServiceSupplier supplier;
@@ -210,15 +212,16 @@
 
 	/**
 	 * Method to log an exception.
-	 * 
+	 *
 	 * @param message
 	 *            The log message.
 	 * @param e
 	 *            The exception that should be logged.
 	 */
 	void logError(String message, Throwable e) {
-		if (this.logService != null) {
-			this.logService.log(LogService.LOG_ERROR, message, e);
+		Logger log = this.logger;
+		if (log != null) {
+			log.error(message, e);
 		} else {
 			// fallback if no LogService is available
 			e.printStackTrace();
@@ -233,4 +236,17 @@
 			});
 		});
 	}
+
+	@Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC)
+	void setLogger(LoggerFactory factory) {
+		this.factory = factory;
+		this.logger = factory.getLogger(getClass());
+	}
+
+	void unsetLogger(LoggerFactory loggerFactory) {
+		if (this.factory == loggerFactory) {
+			this.factory = null;
+			this.logger = null;
+		}
+	}
 }
diff --git a/bundles/org.eclipse.e4.core.services/OSGI-INF/org.eclipse.e4.core.internal.services.MessageFactoryServiceImpl.xml b/bundles/org.eclipse.e4.core.services/OSGI-INF/org.eclipse.e4.core.internal.services.MessageFactoryServiceImpl.xml
index c926aa7..8c65d61 100644
--- a/bundles/org.eclipse.e4.core.services/OSGI-INF/org.eclipse.e4.core.internal.services.MessageFactoryServiceImpl.xml
+++ b/bundles/org.eclipse.e4.core.services/OSGI-INF/org.eclipse.e4.core.internal.services.MessageFactoryServiceImpl.xml
@@ -3,6 +3,6 @@
    <service>
       <provide interface="org.eclipse.e4.core.services.nls.IMessageFactoryService"/>
    </service>
-   <reference bind="setLogService" cardinality="0..1" interface="org.osgi.service.log.LogService" name="LogService" policy="dynamic" unbind="unsetLogService"/>
+   <reference bind="setLogger" cardinality="0..1" interface="org.osgi.service.log.LoggerFactory" name="Logger" policy="dynamic" unbind="unsetLogger"/>
    <implementation class="org.eclipse.e4.core.internal.services.MessageFactoryServiceImpl"/>
 </scr:component>
\ No newline at end of file
diff --git a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/BundleTranslationProvider.java b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/BundleTranslationProvider.java
index cf6eed5..d93f17d 100644
--- a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/BundleTranslationProvider.java
+++ b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/BundleTranslationProvider.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2014 IBM Corporation and others.
+ * Copyright (c) 2011, 2018 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -16,21 +16,21 @@
 import org.eclipse.e4.core.di.annotations.Optional;
 import org.eclipse.e4.core.services.translation.ResourceBundleProvider;
 import org.eclipse.e4.core.services.translation.TranslationService;
-import org.osgi.service.log.LogService;
+import org.osgi.service.log.Logger;
+import org.osgi.service.log.LoggerFactory;
 
 public class BundleTranslationProvider extends TranslationService {
 
 	@Inject
 	ResourceBundleProvider provider;
 
-	@Inject
-	@Optional
-	LogService logService;
+	Logger logger;
 
 	@Override
 	public String translate(String key, String contributorURI) {
-		if (provider == null)
+		if (provider == null) {
 			return key;
+		}
 
 		try {
 			ResourceBundle resourceBundle = ResourceBundleHelper.getResourceBundleForUri(
@@ -39,13 +39,23 @@
 		} catch (Exception e) {
 			// an error occurred on trying to retrieve the translation for the given key
 			// for improved fault tolerance we will log the error and return the key
-			if (logService != null)
-				logService.log(LogService.LOG_ERROR,
-						"Error retrieving the translation for key=" + key //$NON-NLS-1$
-								+ " and contributorURI=" + contributorURI, e); //$NON-NLS-1$
+			Logger log = this.logger;
+			if (log != null) {
+				log.error("Error retrieving the translation for key={} and contributorURI={}", key, contributorURI,
+						e);
+			}
 
 			return key;
 		}
 	}
 
+	@Inject
+	@Optional
+	void setLoggerFactory(LoggerFactory factory) {
+		if (factory != null) {
+			this.logger = factory.getLogger(getClass());
+		} else {
+			this.logger = null;
+		}
+	}
 }
diff --git a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/MessageFactoryServiceImpl.java b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/MessageFactoryServiceImpl.java
index 9a0b9b7..a1721af 100644
--- a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/MessageFactoryServiceImpl.java
+++ b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/MessageFactoryServiceImpl.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2016 BestSolution.at and others.
+ * Copyright (c) 2011, 2018 BestSolution.at and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -36,12 +36,14 @@
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.ReferenceCardinality;
 import org.osgi.service.component.annotations.ReferencePolicy;
-import org.osgi.service.log.LogService;
+import org.osgi.service.log.Logger;
+import org.osgi.service.log.LoggerFactory;
 
 @Component
 public class MessageFactoryServiceImpl implements IMessageFactoryService {
 
-	private LogService logService;
+	private LoggerFactory factory;
+	private Logger logger;
 
 	// Cache so when multiple instance use the same message class
 	private Map<Object, Reference<Object>> SOFT_CACHE = Collections
@@ -169,10 +171,10 @@
 				resourceBundle = ResourceBundleHelper.getResourceBundleForUri(
 						annotation.contributionURI(), locale, rbProvider);
 			} else if (annotation.contributorURI().length() > 0) {
-				if (logService != null) {
-					logService
-							.log(LogService.LOG_WARNING,
-									"Usage of @Message#contributorURI detected! Please use @Message#contributionURI instead!"); //$NON-NLS-1$
+				Logger log = this.logger;
+				if (log != null) {
+					log.warn(
+							"Usage of @Message#contributorURI detected! Please use @Message#contributionURI instead!"); //$NON-NLS-1$
 				}
 				resourceBundle = ResourceBundleHelper.getResourceBundleForUri(
 					annotation.contributorURI(), locale, rbProvider);
@@ -223,11 +225,15 @@
 				}
 			}
 		} catch (InstantiationException e) {
-			if (logService != null)
-				logService.log(LogService.LOG_ERROR, "Instantiation of messages class failed", e); //$NON-NLS-1$
+			Logger log = this.logger;
+			if (log != null) {
+				log.error("Instantiation of messages class failed", e); //$NON-NLS-1$
+			}
 		} catch (IllegalAccessException e) {
-			if (logService != null)
-				logService.log(LogService.LOG_ERROR, "Failed to access messages class", e); //$NON-NLS-1$
+			Logger log = this.logger;
+			if (log != null) {
+				log.error("Failed to access messages class", e); //$NON-NLS-1$
+			}
 		}
 
 		// invoke the method annotated with @PostConstruct
@@ -259,10 +265,12 @@
 					try {
 						method.invoke(messageObject);
 					} catch (Exception e) {
-						if (logService != null)
-							logService
-									.log(LogService.LOG_ERROR,
-											"Exception on trying to execute the @PostConstruct annotated method in " + messageClass, e); //$NON-NLS-1$
+						Logger log = this.logger;
+						if (log != null) {
+							log.error(
+									"Exception on trying to execute the @PostConstruct annotated method in {}", //$NON-NLS-1$
+									messageClass, e);
+						}
 					}
 				}
 			}
@@ -270,13 +278,17 @@
 	}
 
 	@org.osgi.service.component.annotations.Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC)
-	void setLogService(LogService logService) {
-		this.logService = logService;
+	void setLogger(LoggerFactory factory) {
+		this.factory = factory;
+		this.logger = factory.getLogger(getClass());
 	}
 
-	void unsetLogService(LogService logService) {
-		if (this.logService == logService) {
-			this.logService = null;
+	void unsetLogger(LoggerFactory loggerFactory) {
+		if (this.factory == loggerFactory) {
+			// if the factory we referenced locally is unset, we set the logger reference to
+			// null
+			this.factory = null;
+			this.logger = null;
 		}
 	}
 
diff --git a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/ResourceBundleHelper.java b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/ResourceBundleHelper.java
index c765d70..5326430 100644
--- a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/ResourceBundleHelper.java
+++ b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/ResourceBundleHelper.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2014 Dirk Fauth and others.
+ * Copyright (c) 2012, 2018 Dirk Fauth and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -30,13 +30,15 @@
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.log.LogService;
+import org.osgi.service.log.Logger;
+import org.osgi.service.log.LoggerFactory;
 import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
 
 /**
  * Helper class for retrieving {@link ResourceBundle}s out of OSGi {@link Bundle}s.
- *
- * @author Dirk Fauth
  */
 public class ResourceBundleHelper {
 
@@ -74,6 +76,40 @@
 		}
 	}
 
+	private static ServiceTracker<LoggerFactory, Logger> loggerTracker = openLoggerTracker();
+
+	private static ServiceTracker<LoggerFactory, Logger> openLoggerTracker() {
+		try {
+			BundleContext context = FrameworkUtil.getBundle(ResourceBundleHelper.class).getBundleContext();
+			ServiceTracker<LoggerFactory, Logger> tracker = new ServiceTracker<>(
+					context, LoggerFactory.class,
+					new ServiceTrackerCustomizer<LoggerFactory, Logger>() {
+
+						@Override
+						public Logger addingService(ServiceReference<LoggerFactory> reference) {
+							LoggerFactory factory = context.getService(reference);
+							if (factory != null) {
+								return factory.getLogger(ResourceBundleHelper.class);
+							}
+							return null;
+						}
+
+						@Override
+						public void modifiedService(ServiceReference<LoggerFactory> reference, Logger service) {
+						}
+
+						@Override
+						public void removedService(ServiceReference<LoggerFactory> reference, Logger service) {
+							context.ungetService(reference);
+						}
+					});
+			tracker.open();
+			return tracker;
+		} catch (Throwable t) {
+			return null;
+		}
+	}
+
 	/**
 	 * Parses the specified contribution URI and loads the {@link ResourceBundle} for the specified
 	 * {@link Locale} out of an OSGi {@link Bundle}.
@@ -106,15 +142,15 @@
 		if (contributionURI == null)
 			return null;
 
-		LogService logService = logTracker.getService();
+		Logger logger = loggerTracker.getService();
 
 		URI uri;
 		try {
 			uri = new URI(contributionURI);
 		} catch (URISyntaxException e) {
-			if (logService != null)
-				logService
-						.log(LogService.LOG_ERROR, "Invalid contribution URI: " + contributionURI); //$NON-NLS-1$
+			if (logger != null) {
+				logger.error("Invalid contribution URI: {}", contributionURI); //$NON-NLS-1$
+			}
 			return null;
 		}
 
@@ -138,18 +174,17 @@
 			}
 		} else if (BUNDLECLASS_SCHEMA.equals(uri.getScheme())) {
 			if (uri.getAuthority() == null) {
-				if (logService != null)
-					logService.log(LogService.LOG_ERROR,
-							"Failed to get bundle for: " + contributionURI); //$NON-NLS-1$
+				if (logger != null) {
+					logger.error("Failed to get bundle for: {}", contributionURI); //$NON-NLS-1$
+				}
 			}
 			bundleName = uri.getAuthority();
 			// remove the leading /
 			if (uri.getPath() != null && uri.getPath().length() > 0) {
 				classPath = uri.getPath().substring(1);
 			} else {
-				if (logService != null) {
-					logService.log(LogService.LOG_ERROR, "Called with invalid contribution URI: "
-							+ contributionURI);
+				if (logger != null) {
+					logger.error("Called with invalid contribution URI: {}", contributionURI); //$NON-NLS-1$
 				}
 			}
 		}
@@ -168,10 +203,9 @@
 						result = getEquinoxResourceBundle(classPath, locale,
 								resourceBundleClass.getClassLoader());
 					} catch (Exception e) {
-						if (logService != null)
-							logService
-									.log(LogService.LOG_ERROR,
-											"Failed to load specified ResourceBundle: " + contributionURI, e); //$NON-NLS-1$
+						if (logger != null) {
+							logger.error("Failed to load specified ResourceBundle: {}", contributionURI, e); //$NON-NLS-1$
+						}
 					}
 				} else if (resourcePath != null && resourcePath.length() > 0) {
 					// the specified URI points to a resource
@@ -546,12 +580,12 @@
 	 *         default {@link Locale} will be returned.
 	 */
 	public static Locale toLocale(String localeString, Locale defaultLocale) {
-		LogService logService = logTracker.getService();
+		Logger logger = loggerTracker.getService();
 
 		if (localeString == null) {
-			if (logService != null)
-				logService.log(LogService.LOG_ERROR, "Given locale String is null"
-						+ " - Default Locale will be used instead."); //$NON-NLS-1$
+			if (logger != null) {
+				logger.error("Given locale String is null - Default Locale will be used instead."); //$NON-NLS-1$
+			}
 			return defaultLocale;
 		}
 
@@ -562,27 +596,28 @@
 		String[] localeParts = localeString.split("_"); //$NON-NLS-1$
 		if (localeParts.length == 0 || localeParts.length > 3
 				|| (localeParts.length == 1 && localeParts[0].length() == 0)) {
-			logInvalidFormat(localeString, logService);
+			logInvalidFormat(localeString, logger);
 			return defaultLocale;
 		}
 
-		if (localeParts[0].length() > 0 && !localeParts[0].matches("[a-zA-Z]{2,8}")) {
-			logInvalidFormat(localeString, logService);
+		if (localeParts[0].length() > 0 && !localeParts[0].matches("[a-zA-Z]{2,8}")) { //$NON-NLS-1$
+			logInvalidFormat(localeString, logger);
 			return defaultLocale;
 		}
 
 		language = localeParts[0];
 
 		if (localeParts.length > 1) {
-			if (localeParts[1].length() > 0 && !localeParts[1].matches("[a-zA-Z]{2}|[0-9]{3}")) {
+			if (localeParts[1].length() > 0 && !localeParts[1].matches("[a-zA-Z]{2}|[0-9]{3}")) { //$NON-NLS-1$
 				if (language.length() > 0) {
-					if (logService != null)
-						logService.log(LogService.LOG_ERROR, "Invalid locale format: "
-								+ localeString
-								+ " - Only language part will be used to create the Locale."); //$NON-NLS-1$
+					if (logger != null) {
+						logger.error(
+								"Invalid locale format: {} - Only language part will be used to create the Locale.", //$NON-NLS-1$
+								localeString);
+					}
 					return new Locale(language);
 				}
-				logInvalidFormat(localeString, logService);
+				logInvalidFormat(localeString, logger);
 				return defaultLocale;
 			}
 
@@ -591,12 +626,11 @@
 
 		if (localeParts.length == 3) {
 			if (localeParts[2].length() == 0) {
-				if (logService != null)
-					logService
-							.log(LogService.LOG_ERROR,
-									"Invalid locale format: "
-											+ localeString
-											+ " - Only language and country part will be used to create the Locale."); //$NON-NLS-1$
+				if (logger != null) {
+					logger.error(
+							"Invalid locale format: {} - Only language and country part will be used to create the Locale.", //$NON-NLS-1$
+							localeString);
+				}
 				return new Locale(language, country);
 			}
 			variant = localeParts[2];
@@ -607,14 +641,14 @@
 
 	private static HashSet<String> invalidLocalesLogged = new HashSet<>();
 
-	static void logInvalidFormat(String str, LogService logService) {
-		if (logService != null && !invalidLocalesLogged.contains(str)) {
+	static void logInvalidFormat(String str, Logger log) {
+		if (log != null && !invalidLocalesLogged.contains(str)) {
 			invalidLocalesLogged.add(str);
-			logService.log(LogService.LOG_ERROR, "Invalid locale format: " + str
-					+ " - Default Locale will be used instead."); //$NON-NLS-1$
+			log.error("Invalid locale format: {} - Default Locale will be used instead.", str); //$NON-NLS-1$
 		}
 	}
 
+	@Deprecated
 	public static LogService getLogService() {
 		return logTracker.getService();
 	}
@@ -626,9 +660,6 @@
 	 * <p>
 	 * It only supports properties based {@link ResourceBundle}s. If you want to use source based
 	 * {@link ResourceBundle}s you have to use the bundleclass URI with the Message annotation.
-	 *
-	 * @author Dirk Fauth
-	 *
 	 */
 	static class BundleResourceBundleControl extends ResourceBundle.Control {
 
diff --git a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/nls/BaseMessageRegistry.java b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/nls/BaseMessageRegistry.java
index 4966fbb..51c6a54 100644
--- a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/nls/BaseMessageRegistry.java
+++ b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/nls/BaseMessageRegistry.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2014 Dirk Fauth and others.
+ * Copyright (c) 2014, 2018 Dirk Fauth and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -19,8 +19,10 @@
 import java.util.Map;
 import java.util.Map.Entry;
 import javax.annotation.PreDestroy;
-import org.eclipse.e4.core.internal.services.ResourceBundleHelper;
-import org.osgi.service.log.LogService;
+import javax.inject.Inject;
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.osgi.service.log.Logger;
+import org.osgi.service.log.LoggerFactory;
 
 /**
  * Using this MessageRegistry allows to register controls for attributes in a
@@ -68,6 +70,24 @@
 
 	private final Map<MessageConsumer, MessageSupplier> bindings = new HashMap<>();
 
+	private Logger registryLogger;
+	private Logger consumerLogger;
+	private Logger supplierLogger;
+
+	@Inject
+	@Optional
+	void setLoggerFactory(LoggerFactory factory) {
+		if (factory != null) {
+			this.registryLogger = factory.getLogger(BaseMessageRegistry.class);
+			this.consumerLogger = factory.getLogger(MessageConsumerImplementation.class);
+			this.supplierLogger = factory.getLogger(MessageSupplierImplementation.class);
+		} else {
+			this.registryLogger = null;
+			this.consumerLogger = null;
+			this.supplierLogger = null;
+		}
+	}
+
 	/**
 	 * Register a consumer and a function that is acting as the supplier of the translation value.
 	 * <p>
@@ -197,37 +217,33 @@
 	 */
 	protected MessageConsumer createConsumer(final Object control, final String method) {
 
-		final LogService logService = ResourceBundleHelper.getLogService();
-
 		try {
 			final Method m = control.getClass().getMethod(method, String.class);
 			if (m != null) {
-				return new MessageConsumerImplementation(logService, m, control);
+				return new MessageConsumerImplementation(m, control);
 			}
 		} catch (NoSuchMethodException e) {
-			if (logService != null)
-				logService.log(LogService.LOG_WARNING,
-						"The method '" + e.getMessage()
-								+ "' does not exist. Binding is not created!");
+			Logger log = this.registryLogger;
+			if (log != null) {
+				log.warn("The method '{}' does not exist. Binding is not created!", e.getMessage());
+			}
 		} catch (SecurityException e) {
-			if (logService != null)
-				logService.log(
-						LogService.LOG_WARNING,
-						"Error on accessing method '" + method + "' on class '"
-								+ control.getClass() + "' with error message '" + e.getMessage()
-								+ "'. Binding is not created!");
+			Logger log = this.registryLogger;
+			if (log != null) {
+				log.warn(
+						"Error on accessing method '{}' on class '{}' with error message '{}'. Binding is not created!",
+						method, control.getClass(), e.getMessage());
+			}
 		}
 
 		return null;
 	}
 
 	private final class MessageConsumerImplementation implements MessageConsumer {
-		private final LogService logService;
 		private final Method m;
 		private final Object control;
 
-		private MessageConsumerImplementation(LogService logService, Method m, Object control) {
-			this.logService = logService;
+		private MessageConsumerImplementation(Method m, Object control) {
 			this.m = m;
 			this.control = control;
 		}
@@ -254,11 +270,12 @@
 								// binding to avoid further issues e.g. this can
 								// happen in case of disposed SWT controls
 								bindings.remove(MessageConsumerImplementation.this);
-								if (logService != null)
-									logService.log(LogService.LOG_INFO,
-											"Error on invoke '" + m.getName() + "' on '" + control.getClass()
-													+ "' with error message '" + e.getMessage()
-													+ "'. Binding is removed.");
+								Logger log = consumerLogger;
+								if (log != null) {
+									log.info(
+											"Error on invoke '{}' on '{}' with error message '{}'. Binding is removed.",
+											m.getName(), control.getClass(), e.getMessage());
+								}
 							}
 							return null;
 						}
@@ -270,10 +287,11 @@
 				// avoid further issues
 				// e.g. this can happen in case of disposed SWT controls
 				bindings.remove(this);
-				if (logService != null)
-					logService.log(LogService.LOG_INFO,
-							"Error on invoke '" + m.getName() + "' on '" + control.getClass() + "' with error message '"
-									+ e.getMessage() + "'. Binding is removed.");
+				Logger log = consumerLogger;
+				if (log != null) {
+					log.info("Error on invoke '{}' on '{}' with error message '{}'. Binding is removed.",
+							m.getName(), control.getClass(), e.getMessage());
+				}
 			}
 		}
 	}
@@ -285,31 +303,33 @@
 	 * @return A MessageSupplier that returns the message value for the given message key
 	 */
 	protected MessageSupplier createSupplier(final String messageKey) {
-		final LogService logService = ResourceBundleHelper.getLogService();
 		try {
 			final Field f = messages.getClass().getField(messageKey);
 			if (f != null) {
-				return new MessageSupplierImplementation(logService, f);
+				return new MessageSupplierImplementation(f);
 			}
 		} catch (NoSuchFieldException e) {
-			if (logService != null)
-				logService.log(LogService.LOG_WARNING, "The class '" + this.messages.getClass().getName()
-						+ "' does not contain a field with name '" + e.getMessage() + "'. Binding is not created!");
+			Logger log = this.registryLogger;
+			if (log != null) {
+				log.warn(
+						"The class '{}' does not contain a field with name '{}'. Binding is not created!",
+						this.messages.getClass().getName(), e.getMessage());
+			}
 		} catch (SecurityException e) {
-			if (logService != null)
-				logService.log(LogService.LOG_WARNING,
-						"Error on accessing field '" + messageKey + "' on class '" + messages.getClass()
-								+ "' with error message '" + e.getMessage() + "'. Binding is not created!");
+			Logger log = this.registryLogger;
+			if (log != null) {
+				log.warn(
+						"Error on accessing field '{}' on class '{}' with error message '{}'. Binding is not created!",
+						messageKey, messages.getClass(), e.getMessage());
+			}
 		}
 		return null;
 	}
 
 	private final class MessageSupplierImplementation implements MessageSupplier {
-		private final LogService logService;
 		private final Field f;
 
-		private MessageSupplierImplementation(LogService logService, Field f) {
-			this.logService = logService;
+		private MessageSupplierImplementation(Field f) {
 			this.f = f;
 		}
 
@@ -328,10 +348,11 @@
 						iterator.remove();
 					}
 				});
-				if (logService != null)
-					logService.log(LogService.LOG_INFO,
-							"Error on invoke '" + f.getName() + "' on '" + messages.getClass()
-									+ "' with error message '" + e.getMessage() + "'. Binding is removed.");
+				Logger log = supplierLogger;
+				if (log != null) {
+					log.info("Error on invoke '{}' on '{}' with error message '{}'. Binding is removed.",
+							f.getName(), messages.getClass(), e.getMessage());
+				}
 			}
 			return message;
 		}