For debug purpose, I want to print out current executing function name in Java. If it were C, I would just do printf("%s \n" ,__FUNCITON__)
.
new Exception().getStackTrace()[0].getMethodName();
I'd use one of the logging frameworks (logback with slf4j is probably the best one at the moment, but log4j should suffice), then you can specify a layout that will print the method name logback layout documentation here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With