diff --git a/src/main/java/org/jboss/logmanager/LogManager.java b/src/main/java/org/jboss/logmanager/LogManager.java index bf956baa..cf52d3bd 100644 --- a/src/main/java/org/jboss/logmanager/LogManager.java +++ b/src/main/java/org/jboss/logmanager/LogManager.java @@ -119,7 +119,8 @@ private void doConfigure(InputStream inputStream) { if (configurator == null) { int best = Integer.MAX_VALUE; ConfiguratorFactory factory = null; - final ServiceLoader serviceLoader = ServiceLoader.load(ConfiguratorFactory.class); + final ServiceLoader serviceLoader = ServiceLoader.load(ConfiguratorFactory.class, + LogManager.class.getClassLoader()); final Iterator iterator = serviceLoader.iterator(); List problems = null; for (;;) diff --git a/src/main/java/org/jboss/logmanager/configuration/PropertyLogContextConfigurator.java b/src/main/java/org/jboss/logmanager/configuration/PropertyLogContextConfigurator.java index 3622ab84..b24e5945 100644 --- a/src/main/java/org/jboss/logmanager/configuration/PropertyLogContextConfigurator.java +++ b/src/main/java/org/jboss/logmanager/configuration/PropertyLogContextConfigurator.java @@ -77,7 +77,8 @@ public void configure(final LogContext logContext, final InputStream inputStream context.attachIfAbsent(ContextConfiguration.CONTEXT_CONFIGURATION_KEY, configurator); } else { // Next check the service loader - final Iterator serviceLoader = ServiceLoader.load(LogContextConfigurator.class).iterator(); + final Iterator serviceLoader = ServiceLoader + .load(LogContextConfigurator.class, PropertyLogContextConfigurator.class.getClassLoader()).iterator(); if (serviceLoader.hasNext()) { serviceLoader.next().configure(context, null); } else { @@ -95,20 +96,18 @@ public void configure(final LogContext logContext, final InputStream inputStream private static InputStream findConfiguration() { final String propLoc = System.getProperty("logging.configuration"); - if (propLoc != null) + if (propLoc != null) { try { return new URL(propLoc).openStream(); } catch (IOException e) { StandardOutputStreams.printError("Unable to read the logging configuration from '%s' (%s)%n", propLoc, e); } - final ClassLoader tccl = Thread.currentThread().getContextClassLoader(); - if (tccl != null) - try { - final InputStream stream = tccl.getResourceAsStream("logging.properties"); - if (stream != null) - return stream; - } catch (Exception ignore) { - } - return PropertyLogContextConfigurator.class.getResourceAsStream("logging.properties"); + } + final ClassLoader cl = PropertyLogContextConfigurator.class.getClassLoader(); + try { + return cl.getResourceAsStream("logging.properties"); + } catch (Exception ignore) { + return null; + } } }