Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I cheaply call a Java method to get the current method's name?

Tags:

java

Basically I have a logging statement inside of a method. Whenever the method is called, I want to easily call the name of the method, and append it to the logging statement. This is done to minimize the number of hard coded lines in my application. Is this possible to do it cheaply?

like image 901
Jacob Mccain Avatar asked Jul 14 '11 19:07

Jacob Mccain


1 Answers

No, not cheaply. The expensive and only way of doing it is with a StackTrace method call. Best to just hardcode it.

like image 113
TravMan Avatar answered Oct 10 '22 02:10

TravMan