I want to trace the beginning [& ending] of functions called in Java, like the following code:
public void foo() {
System.out.println(\"begin of fo
The easiest approach is the one you've chose.
An easy replacement for the System.out
calls would be using a logging framework. Then you could switch the information on and off according to a selected "logging level"
More sophisticated solutions would use aspect oriented programming techniques (provide by AspectJ, for instance), but this puts you on a steep learning curve.
Maybe a tool-based a approach fits your needs: so called "profilers" can "instrument" your code and report exactly which method was called during a run.