Is there a way to add a logger instance with Spring ? And is there a way to trace each method calls in my custom code ?
I usually do this :
package my.java.code;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class A {
// How to add this line with Spring ?
private static final Logger logger = LoggerFactory.getLogger(A.class);
public void A() {
// How to add this line with Spring ?
logger.trace("");
// Do something...
}
public void A(Object o) {
// How to add this line with Spring ?
logger.trace("{}", o);
// Do something...
}
public void method1() {
// How to add this line with Spring ?
logger.trace("");
// Do something...
}
public void method2(Object o) {
// How to add this line with Spring ?
logger.trace("{}", o);
// Do something...
}
}
Is there a way to simplify this with Spring ?
Goal is :
- avoid repeatitive code