[Bug 235] New: Category class in log4j-over-slf4j does not contain getAllAppenders()

http://bugzilla.slf4j.org/show_bug.cgi?id=235 Summary: Category class in log4j-over-slf4j does not contain getAllAppenders() Product: SLF4J Version: 1.6.x Platform: All OS/Version: All Status: NEW Severity: major Priority: P1 Component: log4j-over-slf4j AssignedTo: slf4j-dev@qos.ch ReportedBy: anthony@whitford.com I am running into the same issue discussed here: http://slf4j.42922.n3.nabble.com/Sigar-and-log4j-over-slf4j-td2165576.html Sigar reports a stack trace like: java.lang.NoSuchMethodError: org.apache.log4j.Logger.getAllAppenders()Ljava/util/Enumeration; at org.hyperic.sigar.SigarLog.isLogConfigured(SigarLog.java:40) at org.hyperic.sigar.SigarLog.getLogger(SigarLog.java:49) at org.hyperic.sigar.SigarLog.getLogger(SigarLog.java:44) at org.hyperic.sigar.SigarLog.debug(SigarLog.java:60) at org.hyperic.sigar.Sigar.<clinit>(Sigar.java:108) And it was traced to the absence of getAllAppenders() in log4j-over-slf4j. Adding the missing method addresses the Sigar issue... public Enumeration getAllAppenders() { return new Enumeration() { public Object nextElement() { return null; } public boolean hasMoreElements() { return false; } }; } I'm unclear if the above method should be properly implemented, or if the mock stub is sufficient. -- Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.

http://bugzilla.slf4j.org/show_bug.cgi?id=235 --- Comment #1 from Anthony Whitford <anthony@whitford.com> 2011-08-20 03:11:55 CEST --- I traced the Sigar code (SigarLog.java) and discovered that they are doing this: private static boolean isLogConfigured() { //funny, log4j has no api to determine if logging has been //configured? .. yet bitches at you like a mo-fo when logging //has not been configured. return Logger.getRootLogger().getAllAppenders().hasMoreElements(); } ... public static Logger getLogger(String name) { Logger log = Logger.getLogger(name); if (!isLogConfigured()) { BasicConfigurator.configure(); } return log; } Presumably, I should be able to replace log4j.jar with log4j-over-slf4j.jar and continue to function. -- Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.

http://bugzilla.slf4j.org/show_bug.cgi?id=235 Holger Hoffstätte <holger@codehaus.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |holger@codehaus.org --- Comment #2 from Holger Hoffstätte <holger@codehaus.org> 2011-08-20 12:04:17 CEST --- (In reply to comment #1)
I traced the Sigar code (SigarLog.java) and discovered that they are doing this:
private static boolean isLogConfigured() {
The sanest approach would probably be to fix this nonsense directly in Sigar, because it's messed up to begin with. There is no reason for a library to know whether logging "is configured", which doesn't even mean anything. -- Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.
participants (1)
-
bugzilla-daemon@pixie.qos.ch