I\'ve been working with a company that, in this current project, has to implement a policy of writing lots of trace logging in code (JAVA) that has already been completed for so
You should take a look at AOP. It enables you to inject code at runtime and thus add logging before/after each method.
Go to Window->Preferences, select Java->Editor->Templates, create a new template named "logmeth" with Pattern i.e.:
if(logger.isDebug())logger.debug("${exception_variable_name} ${return_type} "+getClass().getName()+"${enclosing_method}(${enclosing_method_arguments})"+String.format("***",${enclosing_method_arguments}));
and press OK.
In java Editor write logmeth and press Strg+space+space and Enter and Eclipse will write i.e.:
if(logger.isDebug())logger.debug("e boolean hasFuture(man, woman)"
+ String.format("***", man, woman));
Eclipse is so cool.
You can use interceptors http://docs.oracle.com/javaee/6/tutorial/doc/gkeed.html to intercept calls to public methods without any code changes, it is impossible to use this technique with non-public methods though.
The best way is to use AOP and Java annotations. I would recommend to use @Loggable annotation and an AspectJ aspect from jcabi-aspects (I'm a developer):
@Loggable(Loggable.DEBUG)
public String load(URL url) {
return url.openConnection().getContent();
}