Skip to content

Instantly share code, notes, and snippets.

@xli
Created May 22, 2009 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xli/115935 to your computer and use it in GitHub Desktop.
Save xli/115935 to your computer and use it in GitHub Desktop.
//find out caller's class name (found from log5j)
public static void xxx() {
String name = new Exception().getStackTrace()[1].getClassName();
....
}
// or
String name = Thread.currentThread().getStackTrace()[3].getClassName()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment