Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHristo Iliev2011-09-27 03:21:26 -0400
committerHristo Iliev2011-09-27 03:21:26 -0400
commit1245d0a5a027552852aa621a29728fb8a81f7069 (patch)
treec337e607adc692ca8970a2f0332dcd3aaec9f820
parente5271d368a4f2c8a4206f1561778209594c193ff (diff)
parentff2277ac0e0054442813b521cea112265179da44 (diff)
downloadorg.eclipse.virgo.medic-1245d0a5a027552852aa621a29728fb8a81f7069.tar.gz
org.eclipse.virgo.medic-1245d0a5a027552852aa621a29728fb8a81f7069.tar.xz
org.eclipse.virgo.medic-1245d0a5a027552852aa621a29728fb8a81f7069.zip
Bug 355479: JUL is supported via logging bridge
-rw-r--r--build.versions2
-rw-r--r--org.eclipse.virgo.medic.core/ivy.xml1
-rw-r--r--org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/MedicActivator.java33
-rw-r--r--org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/config/ConfigurationAdminConfigurationProvider.java4
-rw-r--r--org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/config/ConfigurationProvider.java2
-rw-r--r--org.eclipse.virgo.medic.integrationtest/ivy.xml3
-rw-r--r--org.eclipse.virgo.medic.integrationtest/src/test/resources/META-INF/test.config.properties23
7 files changed, 49 insertions, 19 deletions
diff --git a/build.versions b/build.versions
index 8be1c3c..0ab5862 100644
--- a/build.versions
+++ b/build.versions
@@ -1,5 +1,5 @@
# Compile
-ch.qos.logback=0.9.24
+ch.qos.logback=0.9.28
org.slf4j=1.6.1
org.eclipse.osgi=3.7.0.v20110613
org.eclipse.osgi.services=3.3.0.v20110110
diff --git a/org.eclipse.virgo.medic.core/ivy.xml b/org.eclipse.virgo.medic.core/ivy.xml
index 68fa19f..498d871 100644
--- a/org.eclipse.virgo.medic.core/ivy.xml
+++ b/org.eclipse.virgo.medic.core/ivy.xml
@@ -20,6 +20,7 @@
<dependency org="org.eclipse.virgo.medic" name="org.eclipse.virgo.medic" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.slf4j" name="com.springsource.slf4j.api" rev="${org.slf4j}" conf="compile->runtime"/>
+ <dependency org="org.slf4j" name="com.springsource.slf4j.bridge" rev="${org.slf4j}" conf="compile->runtime"/>
<dependency org="org.eclipse.virgo.util" name="org.eclipse.virgo.util.osgi" rev="${org.eclipse.virgo.util}" conf="compile->runtime"/>
<dependency org="ch.qos.logback" name="com.springsource.ch.qos.logback.classic" rev="${ch.qos.logback}" conf="provided, additional->runtime"/>
<dependency org="ch.qos.logback" name="com.springsource.ch.qos.logback.core" rev="${ch.qos.logback}" conf="provided, additional->runtime"/>
diff --git a/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/MedicActivator.java b/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/MedicActivator.java
index fbafcf8..0a05ac8 100644
--- a/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/MedicActivator.java
+++ b/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/MedicActivator.java
@@ -17,6 +17,11 @@ import java.util.Arrays;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.List;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Handler;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleListener;
@@ -25,6 +30,7 @@ import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.ConfigurationListener;
import org.osgi.service.log.LogService;
import org.slf4j.LoggerFactory;
+import org.slf4j.bridge.SLF4JBridgeHandler;
import org.eclipse.equinox.log.ExtendedLogReaderService;
import org.eclipse.virgo.medic.dump.DumpGenerator;
@@ -120,7 +126,7 @@ public final class MedicActivator implements BundleActivator {
if(localLogReaderReference != null){
context.ungetService(localLogReaderReference);
}
- dumpStop();
+ dumpStop();
logStop(context);
}
@@ -143,7 +149,7 @@ public final class MedicActivator implements BundleActivator {
}
}
- private void logStart(BundleContext context, ConfigurationProvider configurationProvider) throws ConfigurationPublicationFailedException {
+ private void logStart(BundleContext context, ConfigurationProvider configurationProvider) throws ConfigurationPublicationFailedException {
StandardContextSelectorDelegate delegate = createContextSelectorDelegate(context);
this.registrationTracker.track(context.registerService(BundleListener.class.getName(), delegate, null));
@@ -169,19 +175,21 @@ public final class MedicActivator implements BundleActivator {
System.setOut(delegatingSysOut);
System.setErr(delegatingSysErr);
- if (Boolean.valueOf(configuration.get(ConfigurationProvider.KEY_LOG_WRAP_SYSOUT))) {
+ if (Boolean.valueOf(configuration.get(ConfigurationProvider.KEY_LOG_WRAP_SYSOUT))) {
publishDelegatingPrintStream(delegatingSysOut, LOGGER_NAME_SYSOUT_DELEGATE, context);
publishPrintStream(this.sysOut, LOGGER_NAME_SYSOUT, context);
System.setOut(wrapPrintStream(System.out, LOGGER_NAME_SYSOUT, LoggingLevel.INFO, stackAccessor, configurationProvider, ConfigurationProvider.KEY_LOG_WRAP_SYSOUT));
}
- if (Boolean.valueOf(configuration.get(ConfigurationProvider.KEY_LOG_WRAP_SYSERR))) {
+ if (Boolean.valueOf(configuration.get(ConfigurationProvider.KEY_LOG_WRAP_SYSERR))) {
publishDelegatingPrintStream(delegatingSysErr, LOGGER_NAME_SYSERR_DELEGATE, context);
publishPrintStream(this.sysErr, LOGGER_NAME_SYSERR, context);
System.setErr(wrapPrintStream(System.err, LOGGER_NAME_SYSERR, LoggingLevel.ERROR, stackAccessor, configurationProvider, ConfigurationProvider.KEY_LOG_WRAP_SYSERR));
}
+
+ configureJavaLogging(Boolean.valueOf(configuration.get(ConfigurationProvider.KEY_ENABLE_JUL_CONSOLE_HANDLER)));
}
private PrintStream wrapPrintStream(PrintStream printStream, String loggerName, LoggingLevel loggingLevel, ExecutionStackAccessor stackAccessor, ConfigurationProvider configurationProvider, String configurationProperty) {
@@ -273,4 +281,21 @@ public final class MedicActivator implements BundleActivator {
BundleSearchingPropertyResourceBundleResolver resourceBundleResolver = new BundleSearchingPropertyResourceBundleResolver();
return new LogBackEventLoggerFactory(resourceBundleResolver, new StandardLocaleResolver(), context.getBundle());
}
+
+ private void configureJavaLogging(boolean enableConsoleHandler) {
+ SLF4JBridgeHandler.install();
+
+ // remove console handler from root logger?
+ if (enableConsoleHandler) {
+ return;
+ }
+
+ Logger rootLogger = Logger.getLogger("");
+ Handler[] handlers = rootLogger.getHandlers();
+ for (Handler handler: handlers) {
+ if (handler instanceof ConsoleHandler) {
+ rootLogger.removeHandler(handler);
+ }
+ }
+ }
}
diff --git a/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/config/ConfigurationAdminConfigurationProvider.java b/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/config/ConfigurationAdminConfigurationProvider.java
index 301df17..9e3984b 100644
--- a/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/config/ConfigurationAdminConfigurationProvider.java
+++ b/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/config/ConfigurationAdminConfigurationProvider.java
@@ -54,7 +54,7 @@ public final class ConfigurationAdminConfigurationProvider implements Configurat
}
}
- private void setPropertiesFromConfigurationAdmin(ServiceReference<ConfigurationAdmin> configAdminReference) {
+ private void setPropertiesFromConfigurationAdmin(ServiceReference<ConfigurationAdmin> configAdminReference) {
ConfigurationAdmin configurationAdmin = this.bundleContext.getService(configAdminReference);
if (configurationAdmin != null) {
@@ -86,7 +86,7 @@ public final class ConfigurationAdminConfigurationProvider implements Configurat
return configuration;
}
- private final class MedicConfigurationListener implements ConfigurationListener {
+ private final class MedicConfigurationListener implements ConfigurationListener {
@SuppressWarnings("unchecked")
public void configurationEvent(ConfigurationEvent configEvent) {
if (CONFIG_ADMIN_PID.equals(configEvent.getPid()) && configEvent.getType() == ConfigurationEvent.CM_UPDATED) {
diff --git a/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/config/ConfigurationProvider.java b/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/config/ConfigurationProvider.java
index 5768de5..08fae62 100644
--- a/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/config/ConfigurationProvider.java
+++ b/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/impl/config/ConfigurationProvider.java
@@ -27,5 +27,7 @@ public interface ConfigurationProvider {
public static final String KEY_LOG_DUMP_PATTERN = "log.dump.pattern";
+ public static final String KEY_ENABLE_JUL_CONSOLE_HANDLER = "log.jul.consoleHandler";
+
Dictionary<String, String> getConfiguration();
}
diff --git a/org.eclipse.virgo.medic.integrationtest/ivy.xml b/org.eclipse.virgo.medic.integrationtest/ivy.xml
index bd5a7f7..1d052bd 100644
--- a/org.eclipse.virgo.medic.integrationtest/ivy.xml
+++ b/org.eclipse.virgo.medic.integrationtest/ivy.xml
@@ -19,13 +19,14 @@
<dependencies>
<dependency org="org.eclipse.osgi" name="org.eclipse.osgi" rev="${org.eclipse.osgi}" conf="compile->runtime"/>
<dependency org="org.slf4j" name="com.springsource.slf4j.api" rev="${org.slf4j}" conf="compile->runtime"/>
+ <dependency org="org.slf4j" name="com.springsource.slf4j.bridge" rev="${org.slf4j}" conf="test->runtime"/>
<dependency org="org.eclipse.virgo.medic" name="org.eclipse.virgo.medic" rev="latest.integration" conf="aspects->runtime"/>
<dependency org="org.aspectj" name="com.springsource.org.aspectj.runtime" rev="${org.aspectj}" conf="aspects->runtime"/>
<dependency org="org.eclipse.virgo.util" name="org.eclipse.virgo.util.common" rev="${org.eclipse.virgo.util}" conf="test->runtime"/>
<dependency org="org.eclipse.virgo.osgi" name="org.eclipse.virgo.osgi.launcher" rev="${org.eclipse.virgo.osgi}" conf="test->runtime"/>
- <dependency org="org.eclipse.virgo.osgi" name="org.eclipse.virgo.osgi.extensions.equinox" rev="${org.eclipse.virgo.osgi}" conf="test->runtime"/>
+ <dependency org="org.eclipse.virgo.osgi" name="org.eclipse.virgo.osgi.extensions.equinox" rev="${org.eclipse.virgo.osgi}" conf="test->runtime"/>
<dependency org="org.junit" name="com.springsource.org.junit" rev="${org.junit}" conf="test->runtime"/>
diff --git a/org.eclipse.virgo.medic.integrationtest/src/test/resources/META-INF/test.config.properties b/org.eclipse.virgo.medic.integrationtest/src/test/resources/META-INF/test.config.properties
index 6d05a00..e59c767 100644
--- a/org.eclipse.virgo.medic.integrationtest/src/test/resources/META-INF/test.config.properties
+++ b/org.eclipse.virgo.medic.integrationtest/src/test/resources/META-INF/test.config.properties
@@ -1,15 +1,16 @@
launcher.bundles=\
-file:../ivy-cache/repository/org.aspectj/com.springsource.org.aspectj.runtime/${org.aspectj}/com.springsource.org.aspectj.runtime-${org.aspectj}.jar@start,\
-file:../ivy-cache/repository/org.slf4j/com.springsource.slf4j.api/${org.slf4j}/com.springsource.slf4j.api-${org.slf4j}.jar@start,\
-file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.common/3.1.0.D-20110926115258/org.eclipse.virgo.util.common-3.1.0.D-20110926115258.jar,\
-file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi/3.1.0.D-20110926115258/org.eclipse.virgo.util.osgi-3.1.0.D-20110926115258.jar,\
-file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.parser.manifest/3.1.0.D-20110926115258/org.eclipse.virgo.util.parser.manifest-3.1.0.D-20110926115258.jar,\
-file:../ivy-cache/repository/org.eclipse.osgi/org.eclipse.osgi.services/${org.eclipse.osgi.services}/org.eclipse.osgi.services-${org.eclipse.osgi.services}.jar,\
-file:../ivy-cache/repository/org.eclipse.osgi/org.eclipse.equinox.cm/${org.eclipse.equinox.cm}/org.eclipse.equinox.cm-${org.eclipse.equinox.cm}.jar@start,\
-file:../org.eclipse.virgo.medic/target/artifacts/org.eclipse.virgo.medic.jar@start,\
-file:../org.eclipse.virgo.medic.core/target/artifacts/org.eclipse.virgo.medic.core.jar@start,\
-file:src/test/resources/config-fragment,\
-file:src/test/resources/appender-fragment
+ file:../ivy-cache/repository/org.aspectj/com.springsource.org.aspectj.runtime/${org.aspectj}/com.springsource.org.aspectj.runtime-${org.aspectj}.jar@start,\
+ file:../ivy-cache/repository/org.slf4j/com.springsource.slf4j.api/${org.slf4j}/com.springsource.slf4j.api-${org.slf4j}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.common/3.1.0.D-20110926115258/org.eclipse.virgo.util.common-3.1.0.D-20110926115258.jar,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi/3.1.0.D-20110926115258/org.eclipse.virgo.util.osgi-3.1.0.D-20110926115258.jar,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.parser.manifest/3.1.0.D-20110926115258/org.eclipse.virgo.util.parser.manifest-3.1.0.D-20110926115258.jar,\
+ file:../ivy-cache/repository/org.eclipse.osgi/org.eclipse.osgi.services/${org.eclipse.osgi.services}/org.eclipse.osgi.services-${org.eclipse.osgi.services}.jar,\
+ file:../ivy-cache/repository/org.eclipse.osgi/org.eclipse.equinox.cm/${org.eclipse.equinox.cm}/org.eclipse.equinox.cm-${org.eclipse.equinox.cm}.jar@start,\
+ file:../ivy-cache/repository/org.slf4j/com.springsource.slf4j.bridge/${org.slf4j}/com.springsource.slf4j.bridge-${org.slf4j}.jar,\
+ file:../org.eclipse.virgo.medic/target/artifacts/org.eclipse.virgo.medic.jar@start,\
+ file:../org.eclipse.virgo.medic.core/target/artifacts/org.eclipse.virgo.medic.core.jar@start,\
+ file:src/test/resources/config-fragment,\
+ file:src/test/resources/appender-fragment
org.eclipse.virgo.test.properties.include=file:../build.versions,file:../build.properties

Back to the top