Priority | P5 |
---|---|
Bug ID | 305 |
Assignee | slf4j-dev@qos.ch |
Summary | Add default logger method |
Severity | enhancement |
Classification | Unclassified |
OS | All |
Reporter | ggerard@gmail.com |
Hardware | All |
Status | NEW |
Version | 1.7.x |
Component | Core API |
Product | SLF4J |
The typical way of adding logging to a class involves a reference to the class itself: private static final Logger kLogger = LoggerFactory.getLogger(MyClass.class); Not all tooling catches renames and whatnot -- I've had several occasions where the old class reference inadvertently came along for the ride and made for misleading logs. I started putting this into a little utility class in my projects to prevent this and I think it would be a good addition to LoggerFactory. While the stacktrace calls might not be the cheapest, it's only hit during class initialization. public static Logger getDefaultClassLogger() { return LoggerFactory.getLogger(Thread.currentThread().getStackTrace()[2].getClassName()); }