http://bugzilla.slf4j.org/show_bug.cgi?id=163

--- Comment #40 from Thomas Mueller <[email protected]> 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.
_______________________________________________
slf4j-dev mailing list
[email protected]
http://qos.ch/mailman/listinfo/slf4j-dev

Reply via email to