Skip to content

Instantly share code, notes, and snippets.

@alex-ber
Last active October 11, 2019 11:25
Show Gist options
  • Save alex-ber/fd29de51599f8098ad0184d668130a7c to your computer and use it in GitHub Desktop.
Save alex-ber/fd29de51599f8098ad0184d668130a7c to your computer and use it in GitHub Desktop.
Scary log definiton and usage
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SomeClass {
private static final Logger log = LoggerFactory.getLogger(new Object() {
}.getClass().getEnclosingClass());
public void foo(){
class Local {};
String name = Local.class.getEnclosingMethod().getName();
log.debug("name"+"()")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment