Here you can find the source of loggerForThisClass()
public static Logger loggerForThisClass()
//package com.java2s; //License from project: Apache License import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class Main { public static Logger loggerForThisClass() { // We use the third stack element; second is this method, first is .getStackTrace() final StackTraceElement myCaller = Thread.currentThread().getStackTrace()[2]; if (!"<clinit>".equals(myCaller.getMethodName())) { throw new RuntimeException("Logger must be static"); }//from www . j a v a 2 s.c o m return LoggerFactory.getLogger(myCaller.getClassName()); } }