- Use logger in a non-static context:
Logger logger = LoggerFactory.getLogger(this.getClass().getName());
- Use logger in a static context(for example in main() method):
static Logger logger = LoggerFactory.getLogger(TheWrapperClassName.class);
Method 1 is prefered, because it has no hard-coding for class name.
static final Logger logger = Logger.getLogger(new Throwable() .getStackTrace()[0].getClassName()); maybe a solution, but may slown down the app.