From aa73830199a4ea98e10dc1e5ef742da7d0786ee9 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 28 Oct 2011 10:57:32 -0700 Subject: [PATCH] Updating java comments to make clear the purpose of this new static{} block --- .../java/org/eclipse/jetty/util/log/Log.java | 21 +++++++++++++++++++ .../org/eclipse/jetty/util/log/Slf4jLog.java | 1 - 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java index 6aeb0dd6c1f..766b3ec09a3 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java @@ -46,18 +46,34 @@ public class Log public final static String EXCEPTION= "EXCEPTION "; public final static String IGNORED= "IGNORED "; + /** + * Logging Configuration Properties + */ protected static Properties __props; + /** + * The {@link Logger} implementation class name + */ public static String __logClass; + /** + * Legacy flag indicating if {@link Log#ignore(Throwable)} methods produce any output in the {@link Logger}s + */ public static boolean __ignored; static { + /* Instantiate a default configuration properties (empty) + */ __props = new Properties(); AccessController.doPrivileged(new PrivilegedAction() { public Object run() { + /* First see if the jetty-logging.properties object exists in the classpath. + * This is an optional feature used by embedded mode use, and test cases to allow for early + * configuration of the Log in situations where access to the System.properties is + * impossible. + */ URL testProps = Log.class.getClassLoader().getResource("jetty-logging.properties"); if (testProps != null) { @@ -78,6 +94,9 @@ public class Log } } + /* Now load the System.properties as-is into the __props, these values will override + * any key conflicts in __props. + */ @SuppressWarnings("unchecked") Enumeration systemKeyEnum = (Enumeration)System.getProperties().propertyNames(); while (systemKeyEnum.hasMoreElements()) @@ -86,6 +105,8 @@ public class Log __props.setProperty(key,System.getProperty(key)); } + /* Now use the configuration properties to configure the Log statics + */ __logClass = __props.getProperty("org.eclipse.jetty.util.log.class","org.eclipse.jetty.util.log.Slf4jLog"); __ignored = Boolean.parseBoolean(__props.getProperty("org.eclipse.jetty.util.log.IGNORED","false")); return null; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/Slf4jLog.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/Slf4jLog.java index 930a6f600c4..2b8e268d1a4 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/Slf4jLog.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/Slf4jLog.java @@ -37,7 +37,6 @@ public class Slf4jLog implements Logger } catch (ClassNotFoundException ex) { - ex.printStackTrace(System.err); throw new NoClassDefFoundError("org.slf4j.impl.StaticLoggerBinder"); }