From 8a1702ba0f1ccd5dec8b4fca59829399313edeac Mon Sep 17 00:00:00 2001
From: Ceki Gulcu In case the the inactive by default Logger name
- mismatch warnings are printed only if the
- Note Logger name mismatch
+ warnings are printed only if the
+ The warning will be printed in case the
- name of the logger specified via a class passed as an argument to
- the LoggerFactory.getLogger(Class) method differs from the name of
- the caller as computed internally by SLF4J.
+ The warning will be printed in case the name of the logger
+ specified via a class passed as an argument to the
+ For example, the following code snippet will result in the warning but only if clazz parameter differs from the name of
+ * the caller as computed internally by SLF4J, a logger name mismatch warning will be
+ * printed but only if the slf4j.detectLoggerNameMismatch system property is
+ * set to true. By default, this property is not set and no warnings will be printed
+ * even in case of a logger name mismatch.
+ *
* @param clazz the returned logger will be named after clazz
* @return logger
+ *
+ *
+ * @see Detected logger name mismatch
*/
@Nonnull
public static Logger getLogger(@Nonnull Class> clazz) {
diff --git a/slf4j-site/pom.xml b/slf4j-site/pom.xml
index f016347c..cb7f9f19 100755
--- a/slf4j-site/pom.xml
+++ b/slf4j-site/pom.xml
@@ -31,7 +31,7 @@
Detected logger name mismatch.
+ Detected logger
+ name mismatch.
- slf4j.detectLoggerNameMismatch system propery is set
- to true.
+ slf4j.detectLoggerNameMismatch system property is set
+ to true. By default, this property is not set and no warnings will
+ be printed even in case of a logger name mismatch.
LoggerFactory.getLogger(Class) method differs from
+ the name of the caller as computed internally by SLF4J.
package com.acme;
+
package com.acme;
import com.foo.Kangaroo;
class Fruit {
@@ -114,26 +116,31 @@ class Fruit {
SLF4J: Detected logger name mismatch. Given name: "com.foo.Kangaroo"; computed name: "com.acme.Fruit".
+ SLF4J: Detected logger name mismatch. Given name: "com.foo.Kangaroo"; computed name: "com.acme.Fruit".
slf4j.detectLoggerNameMismatch system
- propery is set to true.
No warning will be issued for the special case where the class in which the logger is defined is a super-type of the class parameter passed as argument. For example,
-abstract class A {
- // no mismatch warning as class A is a super-type of class B
+ class A {
Logger logger = LoggerFactory.getLogger(getClass());
}
-class B extends A { }
+class B extends A {
+ // no mismatch warning will be issued when B is instantiated
+ // given that class A is a super-type of class B
+}
- In case you come across a mismatch warning which cannot be - explained, then you might have spotted a white elepahant, or a +
If you come across a mismatch warning which cannot be + explained, then you might have spotted a white elephant, that is a very rare occurrence where SLF4J cannot correctly compute the name - of the class where a logger is defined. Please do not hesitate to - file a bug report. + of the class where a logger is defined. We are very interested to + learn about cases where SLF4J fails to correclty compute the name + of the class where a logger is defined. If and when you spot such + a case, please do file a bug + report with us.
diff --git a/slf4j-site/src/site/pages/manual.html b/slf4j-site/src/site/pages/manual.html index becf3577..042a4799 100755 --- a/slf4j-site/src/site/pages/manual.html +++ b/slf4j-site/src/site/pages/manual.html @@ -53,10 +53,11 @@ users are highly encouraged to migrate to SLF4J 1.7.5 or later. -since 1.7.8 Spot incorrectly named
- loggers by setting the slf4j.detectLoggerNameMismatch
- system property to true.
+
since 1.7.8 By setting he
+ slf4j.detectLoggerNameMismatch system property to
+ true, SLF4J can automatically spot incorrectly named
+ loggers.
Spot
incorrectly named loggers by setting the
slf4j.detectLoggerNameMismatch system property to
@@ -40,7 +39,8 @@
Spot incorrectly named
loggers by setting the
slf4j.detectLoggerNameMismatch system property to
- true.
Added MDC.putCloeable method so that it can be used
as a Added JSR305 @Nonnull annotations in LoggerFactory
class. Further annotations are likely to follow.
Numerous small code improvements too minor to be listed + here.
+