[slf4j-dev] [Bug 163] Copy & paste of LoggerFactory.getLogger
bugzilla-daemon at pixie.qos.ch
bugzilla-daemon at pixie.qos.ch
Tue Jul 19 09:22:49 CEST 2011
http://bugzilla.slf4j.org/show_bug.cgi?id=163
--- Comment #40 from Thomas Mueller <thomas.tom.mueller at gmail.com> 2011-07-19 09:22:48 CEST ---
Inspired by
http://beust.com/weblog/2011/07/15/accessing-the-class-object-in-a-static-context/
- a new proposal:
public class Test {
private static Logger logger = LoggerFactory.getCallerLogger();
public static void main(String... args) {
logger.log("Hello");
}
}
public class LoggerFactory {
public static Logger getCallerLogger() {
return new Logger() {{
name = new SecurityManager() {
public Class<?> getClass(int level) {
return getClassContext()[level];
}
}.getClass(3).getName();
}};
}
}
public class Logger {
String name;
public void log(String s) {
System.out.println(name + ": " + s);
}
}
--
Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the slf4j-dev
mailing list