With @Loggable you can tell AnnoJ to generate logging method calls at the beggining of some methods. For example if you have the following class definition
@Loggable
public class InterestingClass{
public void importantMethod(){
//some code here
}
}
AnnoJ will modify importantMethod() to look like this:
importantMethod(){
log("importantMethod called");
//some code here
}
That is you can log when a method gets called without manually writing the logging code. What’s better AnnoJ will log the actual parameter values. Combined with the @ToString annotation this can be a powerful tool.
As with @ToString if you place @Loggable before a class definition then all methods will be logged. If you want to exclude some methods use the @Exclude annotation (just put it before the method you want to leave out). Alternatively you can specify in a String array which methods to include:
@Loggable(methods={"importantMethod"})
public class InterestingClass{
public void importantMethod(){
//other methods
}
}
In this case only importantMethod() will be logged.
If you want that all methods of all classes of a package be logged just define a public class called PackageInfo and annotate it with @Loggable (you cant use parameters here).
The @Loggable annotation uses Log4j so you must provide a properly configured log4j.properties file in the root of your application.
As with the other annotations to use @Loggable you must bootstrap your application.


[...] is asked to load a class it checks if its methods/fields or the entire class is annotated with @Loggable, @ToString or @Exclude. After that it tries to transform the bytecode of the class according to the [...]