diff --git a/integration/pom.xml b/integration/pom.xml index c8a3319..0625ffb 100644 --- a/integration/pom.xml +++ b/integration/pom.xml @@ -7,7 +7,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 integration diff --git a/integration/src/test/java/org/slf4j/test_osgi/FelixHost.java b/integration/src/test/java/org/slf4j/test_osgi/FelixHost.java index c0159a3..738a971 100644 --- a/integration/src/test/java/org/slf4j/test_osgi/FelixHost.java +++ b/integration/src/test/java/org/slf4j/test_osgi/FelixHost.java @@ -41,7 +41,7 @@ * Runs a hosted version of Felix for testing purposes. Any bundle errors are * reported via the FrameworkListener passed to the constructor. * - * @author Ceki Gücü + * @author Ceki Gülcü */ public class FelixHost { diff --git a/jcl-over-slf4j/pom.xml b/jcl-over-slf4j/pom.xml index ec0c4f3..8c08e24 100644 --- a/jcl-over-slf4j/pom.xml +++ b/jcl-over-slf4j/pom.xml @@ -5,7 +5,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 4.0.0 diff --git a/jcl-over-slf4j/src/main/java/org/apache/commons/logging/LogFactory.java b/jcl-over-slf4j/src/main/java/org/apache/commons/logging/LogFactory.java index 14e60de..5745d3e 100644 --- a/jcl-over-slf4j/src/main/java/org/apache/commons/logging/LogFactory.java +++ b/jcl-over-slf4j/src/main/java/org/apache/commons/logging/LogFactory.java @@ -321,9 +321,9 @@ * Returns a string that uniquely identifies the specified object, including * its class. *

- * The returned string is of form "classname@hashcode", ie is the same as the + * The returned string is of form "classname@hashcode", i.e. is the same as the * return value of the Object.toString() method, but works even when the - * specified object's class has overidden the toString method. + * specified object's class has overridden the toString method. * * @param o * may be null. diff --git a/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SimpleLog.java b/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SimpleLog.java index 65c7508..4a9bd0d 100644 --- a/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SimpleLog.java +++ b/jcl-over-slf4j/src/main/java/org/apache/commons/logging/impl/SimpleLog.java @@ -87,7 +87,7 @@ /** Properties loaded from simplelog.properties */ static protected final Properties simpleLogProps = new Properties(); - /** The default format to use when formating dates */ + /** The default format to use when formatting dates */ static protected final String DEFAULT_DATE_TIME_FORMAT = "yyyy/MM/dd HH:mm:ss:SSS zzz"; /** Include the instance name in the log message? */ @@ -157,10 +157,15 @@ if (null != in) { try { simpleLogProps.load(in); - in.close(); } catch (java.io.IOException e) { // ignored - } + } finally { + try { + in.close(); + } catch (java.io.IOException e) { + // ignored + } + } } showLogName = getBooleanProperty(systemPrefix + "showlogname", showLogName); diff --git a/jul-to-slf4j/pom.xml b/jul-to-slf4j/pom.xml index b4d604d..31feeea 100644 --- a/jul-to-slf4j/pom.xml +++ b/jul-to-slf4j/pom.xml @@ -7,7 +7,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 jul-to-slf4j diff --git a/log4j-over-slf4j/pom.xml b/log4j-over-slf4j/pom.xml index 4a26117..40595c6 100644 --- a/log4j-over-slf4j/pom.xml +++ b/log4j-over-slf4j/pom.xml @@ -7,7 +7,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/Appender.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/Appender.java index d832a8f..824513c 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/Appender.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/Appender.java @@ -118,7 +118,7 @@ * disposal. If this method returns false, meaning that * a layout is not required, then layout configuration will be * skipped even if there is available layout configuration - * information at the disposal of the configurator.. + * information at the disposal of the configurator. *

*

In the rather exceptional case, where the appender * implementation admits a layout but can also work without it, then diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java index 27f567b..23230ea 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java @@ -145,7 +145,7 @@ } /** - * Delegates tob {@link org.slf4j.Logger#isWarnEnabled} method in SLF4J + * Delegates to {@link org.slf4j.Logger#isWarnEnabled} method in SLF4J */ public boolean isWarnEnabled() { return slf4jLogger.isWarnEnabled(); diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/Level.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/Level.java index ef10e74..24d15aa 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/Level.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/Level.java @@ -209,13 +209,13 @@ /** * Resolved deserialized level to one of the stock instances. - * May be overriden in classes derived from Level. + * May be overridden in classes derived from Level. * @return resolved object. * @throws ObjectStreamException if exception during resolution. */ private Object readResolve() throws ObjectStreamException { // - // if the deserizalized object is exactly an instance of Level + // if the deserialized object is exactly an instance of Level // if (getClass() == Level.class) { return toLevel(level); diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java index 1b25219..05d934d 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java @@ -19,7 +19,7 @@ import org.apache.log4j.*; /** - Listen to events occuring within a {@link + Listen to events occurring within a {@link org.apache.log4j.Hierarchy Hierarchy}. @author Ceki Gülcü diff --git a/log4j-over-slf4j/src/test/java/org/apache/log4j/NDCTest.java b/log4j-over-slf4j/src/test/java/org/apache/log4j/NDCTest.java index 0df8847..82e2326 100644 --- a/log4j-over-slf4j/src/test/java/org/apache/log4j/NDCTest.java +++ b/log4j-over-slf4j/src/test/java/org/apache/log4j/NDCTest.java @@ -31,7 +31,7 @@ import org.junit.Test; /** - * @author Ceki Gücü + * @author Ceki Gülcü */ public class NDCTest { diff --git a/osgi-over-slf4j/pom.xml b/osgi-over-slf4j/pom.xml index 998ddd4..ac3a468 100644 --- a/osgi-over-slf4j/pom.xml +++ b/osgi-over-slf4j/pom.xml @@ -7,7 +7,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 osgi-over-slf4j diff --git a/pom.xml b/pom.xml index 43ae5ee..5c4f7ef 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 pom SLF4J @@ -408,8 +408,8 @@ - tao - scp://tao.qos.ch/var/www/www.slf4j.org/htdocs/ + qos_ch + scp://te.qos.ch/var/www/www.slf4j.org/htdocs/ diff --git a/slf4j-android/pom.xml b/slf4j-android/pom.xml index 05a6480..2442e54 100644 --- a/slf4j-android/pom.xml +++ b/slf4j-android/pom.xml @@ -7,7 +7,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 slf4j-android diff --git a/slf4j-android/src/test/java/org/slf4j/impl/AndroidLoggerFactoryTest.java b/slf4j-android/src/test/java/org/slf4j/impl/AndroidLoggerFactoryTest.java index b38742f..993474f 100644 --- a/slf4j-android/src/test/java/org/slf4j/impl/AndroidLoggerFactoryTest.java +++ b/slf4j-android/src/test/java/org/slf4j/impl/AndroidLoggerFactoryTest.java @@ -26,7 +26,7 @@ import org.junit.Test; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; public class AndroidLoggerFactoryTest { @Test diff --git a/slf4j-api/pom.xml b/slf4j-api/pom.xml index dc9466c..75cfdb6 100644 --- a/slf4j-api/pom.xml +++ b/slf4j-api/pom.xml @@ -7,7 +7,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 slf4j-api diff --git a/slf4j-api/src/main/java/org/slf4j/MDC.java b/slf4j-api/src/main/java/org/slf4j/MDC.java index 49ce2b7..3136f4d 100644 --- a/slf4j-api/src/main/java/org/slf4j/MDC.java +++ b/slf4j-api/src/main/java/org/slf4j/MDC.java @@ -42,7 +42,7 @@ * i.e. this class, will delegate to the underlying system's MDC. Note that at * this time, only two logging systems, namely log4j and logback, offer MDC * functionality. For java.util.logging which does not support MDC, - * {@link BasicMDCAdapter} will be used. For other systems, i.e slf4j-simple + * {@link BasicMDCAdapter} will be used. For other systems, i.e. slf4j-simple * and slf4j-nop, {@link NOPMDCAdapter} will be used. * *

diff --git a/slf4j-api/src/main/java/org/slf4j/helpers/NOPLogger.java b/slf4j-api/src/main/java/org/slf4j/helpers/NOPLogger.java index 6b2fe3d..38bf567 100644 --- a/slf4j-api/src/main/java/org/slf4j/helpers/NOPLogger.java +++ b/slf4j-api/src/main/java/org/slf4j/helpers/NOPLogger.java @@ -42,7 +42,7 @@ public static final NOPLogger NOP_LOGGER = new NOPLogger(); /** - * There is no point in creating multiple instances of NOPLOgger, + * There is no point in creating multiple instances of NOPLogger, * except by derived classes, hence the protected access for the constructor. */ protected NOPLogger() { diff --git a/slf4j-api/src/main/java/org/slf4j/helpers/NamedLoggerBase.java b/slf4j-api/src/main/java/org/slf4j/helpers/NamedLoggerBase.java index ad0b6c9..6e1cce1 100644 --- a/slf4j-api/src/main/java/org/slf4j/helpers/NamedLoggerBase.java +++ b/slf4j-api/src/main/java/org/slf4j/helpers/NamedLoggerBase.java @@ -32,9 +32,10 @@ /** * Serves as base class for named logger implementation. More significantly, this - * class establishes deserialization behavior. See @see #readResolve. + * class establishes deserialization behavior. * * @author Ceki Gulcu + * @see #readResolve * @since 1.5.3 */ abstract class NamedLoggerBase implements Logger, Serializable { diff --git a/slf4j-api/src/main/java/org/slf4j/spi/LoggerFactoryBinder.java b/slf4j-api/src/main/java/org/slf4j/spi/LoggerFactoryBinder.java index 9a23116..923f8a0 100644 --- a/slf4j-api/src/main/java/org/slf4j/spi/LoggerFactoryBinder.java +++ b/slf4j-api/src/main/java/org/slf4j/spi/LoggerFactoryBinder.java @@ -47,9 +47,9 @@ * The String form of the {@link ILoggerFactory} object that this * LoggerFactoryBinder instance is intended to return. * - *

This method allows the developer to intterogate this binder's intention + *

This method allows the developer to interrogate this binder's intention * which may be different from the {@link ILoggerFactory} instance it is able to - * yield in practice. The discrepency should only occur in case of errors. + * yield in practice. The discrepancy should only occur in case of errors. * * @return the class name of the intended {@link ILoggerFactory} instance */ diff --git a/slf4j-api/src/main/java/org/slf4j/spi/MDCAdapter.java b/slf4j-api/src/main/java/org/slf4j/spi/MDCAdapter.java index 2ac0af8..0ccbb87 100644 --- a/slf4j-api/src/main/java/org/slf4j/spi/MDCAdapter.java +++ b/slf4j-api/src/main/java/org/slf4j/spi/MDCAdapter.java @@ -38,7 +38,7 @@ /** * Put a context value (the val parameter) as identified with * the key parameter into the current thread's context map. - * The key parameter cannot be null. The code>val parameter + * The key parameter cannot be null. The val parameter * can be null only if the underlying implementation supports it. * *

If the current thread does not have a context map it is created as a side diff --git a/slf4j-api/src/main/java/org/slf4j/spi/MarkerFactoryBinder.java b/slf4j-api/src/main/java/org/slf4j/spi/MarkerFactoryBinder.java index c9bd5b9..19e34bd 100644 --- a/slf4j-api/src/main/java/org/slf4j/spi/MarkerFactoryBinder.java +++ b/slf4j-api/src/main/java/org/slf4j/spi/MarkerFactoryBinder.java @@ -47,9 +47,9 @@ * The String form of the {@link IMarkerFactory} object that this * MarkerFactoryBinder instance is intended to return. * - *

This method allows the developer to intterogate this binder's intention + *

This method allows the developer to interrogate this binder's intention * which may be different from the {@link IMarkerFactory} instance it is able to - * return. Such a discrepency should only occur in case of errors. + * return. Such a discrepancy should only occur in case of errors. * * @return the class name of the intended {@link IMarkerFactory} instance */ diff --git a/slf4j-api/src/test/java/org/slf4j/FindStaticLoggerBinderPathsPerfTest.hava b/slf4j-api/src/test/java/org/slf4j/FindStaticLoggerBinderPathsPerfTest.hava new file mode 100644 index 0000000..9c3fdd2 --- /dev/null +++ b/slf4j-api/src/test/java/org/slf4j/FindStaticLoggerBinderPathsPerfTest.hava @@ -0,0 +1,55 @@ +package org.slf4j; + +import org.junit.Ignore; +import org.junit.Test; + +public class FindStaticLoggerBinderPathsPerfTest { + + @Test + @Ignore + public void test() { + long duration = timeFindBindingSetCall(); + System.out.println(duration / (1000) + " microseconds"); + + int count = 10; + long sum = 0; + for (int i = 0; i < count; i++) { + sum += timeFindBindingSetCall(); + } + System.out.println(sum / (count * 1000) + " microseconds in average"); + } + + @Test + public void testAsync() throws InterruptedException { + long start = System.nanoTime(); + FindPathSetThread thread = new FindPathSetThread(); + thread.start(); + long end = System.nanoTime(); + + long duration = end - start; + System.out.println(duration / (1000) + " microseconds"); + + thread.join(); + } + + long timeFindBindingSetCall() { + long start = System.nanoTime(); + + LoggerFactory.findPossibleStaticLoggerBinderPathSet(); + long end = System.nanoTime(); + return end - start; + + } + + static class FindPathSetThread extends Thread { + + public void run() { + long start = System.nanoTime(); + LoggerFactory.findPossibleStaticLoggerBinderPathSet(); + long end = System.nanoTime(); + + System.out.println("Found set in " + (end - start)/1000 + " microseconds"); + + } + } +} diff --git a/slf4j-ext/pom.xml b/slf4j-ext/pom.xml index 89425e1..0e7b649 100644 --- a/slf4j-ext/pom.xml +++ b/slf4j-ext/pom.xml @@ -7,7 +7,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 slf4j-ext diff --git a/slf4j-ext/src/main/java/org/slf4j/cal10n/LocLoggerFactory.java b/slf4j-ext/src/main/java/org/slf4j/cal10n/LocLoggerFactory.java index 4ddff60..3067cc7 100644 --- a/slf4j-ext/src/main/java/org/slf4j/cal10n/LocLoggerFactory.java +++ b/slf4j-ext/src/main/java/org/slf4j/cal10n/LocLoggerFactory.java @@ -41,7 +41,7 @@ * instance does have any state beyond that of the {@link Logger} instance it * wraps and its message conveyor. * - * @author Ceki Gücü + * @author Ceki Gülcü * */ public class LocLoggerFactory { diff --git a/slf4j-ext/src/main/java/org/slf4j/ext/EventData.java b/slf4j-ext/src/main/java/org/slf4j/ext/EventData.java index b345789..dc5b502 100644 --- a/slf4j-ext/src/main/java/org/slf4j/ext/EventData.java +++ b/slf4j-ext/src/main/java/org/slf4j/ext/EventData.java @@ -88,7 +88,7 @@ /** * Serialize all the EventData items into an XML representation. * - * @return an XML String containing all the EventDAta items. + * @return an XML String containing all the EventData items. */ public String toXML() { return toXML(eventData); @@ -98,7 +98,7 @@ * Serialize all the EventData items into an XML representation. * * @param map the Map to transform - * @return an XML String containing all the EventDAta items. + * @return an XML String containing all the EventData items. */ public static String toXML(Map map) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -243,7 +243,7 @@ } /** - * Returns an Iterator over all the entries in the EventDAta. + * Returns an Iterator over all the entries in the EventData. * * @return an Iterator that can be used to access all the event attributes. */ diff --git a/slf4j-ext/src/main/java/org/slf4j/ext/EventException.java b/slf4j-ext/src/main/java/org/slf4j/ext/EventException.java index 5009e1b..d4dc3f9 100644 --- a/slf4j-ext/src/main/java/org/slf4j/ext/EventException.java +++ b/slf4j-ext/src/main/java/org/slf4j/ext/EventException.java @@ -58,7 +58,7 @@ * Constructor that chains another Exception or Error and also allows a message * to be specified. * @param exceptionMessage The exception message. - * @param originalException The original excepton. + * @param originalException The original exception. */ public EventException(String exceptionMessage, Throwable originalException) { super(exceptionMessage, originalException); diff --git a/slf4j-ext/src/main/java/org/slf4j/instrumentation/JavassistHelper.java b/slf4j-ext/src/main/java/org/slf4j/instrumentation/JavassistHelper.java index 8096f36..3e0e14e 100644 --- a/slf4j-ext/src/main/java/org/slf4j/instrumentation/JavassistHelper.java +++ b/slf4j-ext/src/main/java/org/slf4j/instrumentation/JavassistHelper.java @@ -40,9 +40,9 @@ public class JavassistHelper { /** - * Create a javaassist source snippet which either is empty (for anything + * Create a javassist source snippet which either is empty (for anything * which does not return a value) or a explanatory text around the $_ - * javaassist return value variable. + * javassist return value variable. * * @param method * descriptor of method @@ -82,7 +82,7 @@ } /** - * Return javaassist source snippet which lists all the parameters and their + * Return javassist source snippet which lists all the parameters and their * values. If available the source names are extracted from the debug * information and used, otherwise just a number is shown. * diff --git a/slf4j-ext/src/main/java/org/slf4j/instrumentation/LogTransformer.java b/slf4j-ext/src/main/java/org/slf4j/instrumentation/LogTransformer.java index 050084e..0089bd4 100644 --- a/slf4j-ext/src/main/java/org/slf4j/instrumentation/LogTransformer.java +++ b/slf4j-ext/src/main/java/org/slf4j/instrumentation/LogTransformer.java @@ -80,7 +80,7 @@ /** * Should each method log entry (with parameters) and exit (with parameters - * and returnvalue)? + * and return value)? * * @param b * value of flag diff --git a/slf4j-ext/src/main/java/org/slf4j/profiler/Profiler.java b/slf4j-ext/src/main/java/org/slf4j/profiler/Profiler.java index 6810938..6557416 100644 --- a/slf4j-ext/src/main/java/org/slf4j/profiler/Profiler.java +++ b/slf4j-ext/src/main/java/org/slf4j/profiler/Profiler.java @@ -214,7 +214,7 @@ } /** - * Return a copy of the global stopwath of this Profiler instance. + * Return a copy of the global stopwatch of this Profiler instance. * * @return a copy of this instance's global stop watch * @since 1.5.9 diff --git a/slf4j-ext/src/main/java/org/slf4j/profiler/StopWatch.java b/slf4j-ext/src/main/java/org/slf4j/profiler/StopWatch.java index 2fc6600..a2891b8 100644 --- a/slf4j-ext/src/main/java/org/slf4j/profiler/StopWatch.java +++ b/slf4j-ext/src/main/java/org/slf4j/profiler/StopWatch.java @@ -25,7 +25,7 @@ package org.slf4j.profiler; /** - * A very basic @{link TimeInstrument} which can be started and stopped + * A very basic {@link TimeInstrument} which can be started and stopped * once and only once. * * @author Ceki Gülcü diff --git a/slf4j-ext/src/main/java/org/slf4j/profiler/TimeInstrument.java b/slf4j-ext/src/main/java/org/slf4j/profiler/TimeInstrument.java index 3f91fd6..92456fc 100644 --- a/slf4j-ext/src/main/java/org/slf4j/profiler/TimeInstrument.java +++ b/slf4j-ext/src/main/java/org/slf4j/profiler/TimeInstrument.java @@ -43,7 +43,7 @@ TimeInstrumentStatus getStatus(); /** - * Start tis time instrument. + * Start this time instrument. * * @param name */ diff --git a/slf4j-jcl/pom.xml b/slf4j-jcl/pom.xml index b450da1..6089c30 100644 --- a/slf4j-jcl/pom.xml +++ b/slf4j-jcl/pom.xml @@ -7,7 +7,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 slf4j-jcl diff --git a/slf4j-jdk14/pom.xml b/slf4j-jdk14/pom.xml index e6263ee..104589b 100644 --- a/slf4j-jdk14/pom.xml +++ b/slf4j-jdk14/pom.xml @@ -7,7 +7,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 slf4j-jdk14 diff --git a/slf4j-jdk14/src/test/java/org/slf4j/InvocationTest.java b/slf4j-jdk14/src/test/java/org/slf4j/InvocationTest.java index 6f28268..e3558c1 100644 --- a/slf4j-jdk14/src/test/java/org/slf4j/InvocationTest.java +++ b/slf4j-jdk14/src/test/java/org/slf4j/InvocationTest.java @@ -35,8 +35,8 @@ import java.util.logging.Level; import java.util.logging.LogRecord; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertNull; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; diff --git a/slf4j-jdk14/src/test/java/org/slf4j/impl/PerfTest.java b/slf4j-jdk14/src/test/java/org/slf4j/impl/PerfTest.java index 77635f7..9ff72d5 100644 --- a/slf4j-jdk14/src/test/java/org/slf4j/impl/PerfTest.java +++ b/slf4j-jdk14/src/test/java/org/slf4j/impl/PerfTest.java @@ -47,7 +47,7 @@ // when the code is guarded by a logger.isLoggable condition, // duration is about 16 *micro*seconds for 1000 iterations // when it is not guarded the figure is 90 milliseconds, - // i.e a ration of 1 to 5000 + // i.e. a ration of 1 to 5000 } double debugLoop(int len) { diff --git a/slf4j-jdk14/src/test/java/org/slf4j/issue/LoggerSerializationTest.java b/slf4j-jdk14/src/test/java/org/slf4j/issue/LoggerSerializationTest.java index 41ed758..a408b93 100644 --- a/slf4j-jdk14/src/test/java/org/slf4j/issue/LoggerSerializationTest.java +++ b/slf4j-jdk14/src/test/java/org/slf4j/issue/LoggerSerializationTest.java @@ -32,7 +32,7 @@ import java.io.ObjectOutputStream; import java.io.Serializable; -import junit.framework.Assert; +import static org.junit.Assert.assertNotNull; import org.junit.Test; import org.slf4j.Logger; @@ -76,8 +76,8 @@ ObjectInputStream in = new ObjectInputStream(is); LoggerHolder lh2 = (LoggerHolder) in.readObject(); - Assert.assertNotNull(lh2); - Assert.assertNotNull(lh2.getLog()); + assertNotNull(lh2); + assertNotNull(lh2.getLog()); lh2.getLog().info("You must see this message as a log message"); } diff --git a/slf4j-log4j12/pom.xml b/slf4j-log4j12/pom.xml index 4974dfd..ed07606 100644 --- a/slf4j-log4j12/pom.xml +++ b/slf4j-log4j12/pom.xml @@ -7,7 +7,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 slf4j-log4j12 diff --git a/slf4j-migrator/pom.xml b/slf4j-migrator/pom.xml index abfe930..e67c1d3 100644 --- a/slf4j-migrator/pom.xml +++ b/slf4j-migrator/pom.xml @@ -7,7 +7,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 slf4j-migrator diff --git a/slf4j-migrator/src/test/java/org/slf4j/migrator/AternativeApproach.java b/slf4j-migrator/src/test/java/org/slf4j/migrator/AternativeApproach.java index da568f9..e5aa2bc 100644 --- a/slf4j-migrator/src/test/java/org/slf4j/migrator/AternativeApproach.java +++ b/slf4j-migrator/src/test/java/org/slf4j/migrator/AternativeApproach.java @@ -55,7 +55,7 @@ /** * In this test we replace, using the simple Pattern (Log), the full Log - * declaration and instanciation. This is not convenient because we will also + * declaration and instantiation. This is not convenient because we will also * replace all String containing "Log". */ public void test2() { @@ -82,7 +82,7 @@ } /** - * In this test we use a simple Pattern to replace the log instanciation + * In this test we use a simple Pattern to replace the log instantiation * without influence on Log declaration. * */ @@ -101,7 +101,7 @@ /** * In this test we try to replace keyword Log without influence on String - * containg Log We see that we have to use two differents Patterns + * containing Log We see that we have to use two different Patterns */ public void test4() { Pattern pat = Pattern.compile("(\\sLog\\b)"); diff --git a/slf4j-nop/pom.xml b/slf4j-nop/pom.xml index 966fc97..f1ab6dc 100644 --- a/slf4j-nop/pom.xml +++ b/slf4j-nop/pom.xml @@ -7,7 +7,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 slf4j-nop diff --git a/slf4j-simple/pom.xml b/slf4j-simple/pom.xml index 3e28b51..253ad14 100644 --- a/slf4j-simple/pom.xml +++ b/slf4j-simple/pom.xml @@ -7,7 +7,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 slf4j-simple diff --git a/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java b/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java index 4f95260..1c401ed 100644 --- a/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java +++ b/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java @@ -53,10 +53,10 @@ * the special values "System.out" and "System.err". Default is "System.err". * *

  • org.slf4j.simpleLogger.defaultLogLevel - Default log level for all instances of SimpleLogger. - * Must be one of ("trace", "debug", "info", "warn", or "error"). If not specified, defaults to "info".
  • + * Must be one of ("trace", "debug", "info", "warn", "error" or "off"). If not specified, defaults to "info". * *
  • org.slf4j.simpleLogger.log.a.b.c - Logging detail level for a SimpleLogger instance - * named "a.b.c". Right-side value must be one of "trace", "debug", "info", "warn", or "error". When a SimpleLogger + * named "a.b.c". Right-side value must be one of "trace", "debug", "info", "warn", "error" or "off". When a SimpleLogger * named "a.b.c" is initialized, its level is assigned from this property. If unspecified, the level of nearest parent * logger will be used, and if none is set, then the value specified by * org.slf4j.simpleLogger.defaultLogLevel will be used.
  • @@ -129,6 +129,9 @@ private static final int LOG_LEVEL_INFO = LocationAwareLogger.INFO_INT; private static final int LOG_LEVEL_WARN = LocationAwareLogger.WARN_INT; private static final int LOG_LEVEL_ERROR = LocationAwareLogger.ERROR_INT; + // The OFF level can only be used in configuration files to disable logging. It has + // no printing method associated with it in o.s.Logger interface. + private static final int LOG_LEVEL_OFF = LOG_LEVEL_ERROR + 10; private static boolean INITIALIZED = false; @@ -179,14 +182,15 @@ return (prop == null) ? defaultValue : "true".equalsIgnoreCase(prop); } - // Initialize class attributes. - // Load properties file, if found. - // Override with system properties. - static void init() { + static void lazyInit() { if (INITIALIZED) { return; } INITIALIZED = true; + init(); + } + + static void init() { loadProperties(); String defaultLogLevelString = getStringProperty(DEFAULT_LOG_LEVEL_KEY, null); @@ -245,9 +249,14 @@ if (null != in) { try { SIMPLE_LOGGER_PROPS.load(in); - in.close(); } catch (java.io.IOException e) { // ignored + } finally { + try { + in.close(); + } catch (java.io.IOException e) { + // ignored + } } } } @@ -295,6 +304,8 @@ return LOG_LEVEL_WARN; } else if ("error".equalsIgnoreCase(levelStr)) { return LOG_LEVEL_ERROR; + } else if ("off".equalsIgnoreCase(levelStr)) { + return LOG_LEVEL_OFF; } // assume INFO by default return LOG_LEVEL_INFO; diff --git a/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLoggerFactory.java b/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLoggerFactory.java index 66f8910..0732bfb 100644 --- a/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLoggerFactory.java +++ b/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLoggerFactory.java @@ -42,7 +42,7 @@ public SimpleLoggerFactory() { loggerMap = new ConcurrentHashMap(); - SimpleLogger.init(); + SimpleLogger.lazyInit(); } /** diff --git a/slf4j-simple/src/test/java/org/slf4j/impl/SimpleLoggerTest.java b/slf4j-simple/src/test/java/org/slf4j/impl/SimpleLoggerTest.java index 0a1680a..812c3e2 100644 --- a/slf4j-simple/src/test/java/org/slf4j/impl/SimpleLoggerTest.java +++ b/slf4j-simple/src/test/java/org/slf4j/impl/SimpleLoggerTest.java @@ -28,8 +28,7 @@ import org.junit.Before; import org.junit.Test; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNull; +import static org.junit.Assert.*; public class SimpleLoggerTest { @@ -51,6 +50,14 @@ assertEquals("info", simpleLogger.recursivelyComputeLevelString()); } + @Test + public void offLevel() { + System.setProperty(A_KEY, "off"); + SimpleLogger simpleLogger = new SimpleLogger("a"); + assertEquals("off", simpleLogger.recursivelyComputeLevelString()); + assertFalse(simpleLogger.isErrorEnabled()); + } + @Test public void loggerNameWithNoDots_WithLevel() { SimpleLogger simpleLogger = new SimpleLogger("a"); diff --git a/slf4j-site/pom.xml b/slf4j-site/pom.xml index d681e09..cae0048 100644 --- a/slf4j-site/pom.xml +++ b/slf4j-site/pom.xml @@ -7,7 +7,7 @@ org.slf4j slf4j-parent - 1.7.21 + 1.7.22 slf4j-site