protected final Logger log = LoggerFactory.getLogger(this.getClass());
First of all you should use slf4j , bridge every log framework to slf4j, then use logback as implementation for logging.
Then simply add or edit your logback configuration introducing the caller class as parameter. For example if you have a logback.xml file like this:
change it into:%-5level %logger - %msg %xEx%n
%-5level %class - %msg %xEx%n
Now the problem is solved but remember: you are paying with performance, finding the caller requires more computational time than printing logger's name.
Related posts: