0

I log the beginning and the end of my methods like this:

public class Foo {
    public void doSomething() {
        logger.debug(“doSomething is being called”);
        // do stuff
        logger.debug(“Finished calling doSomething”);
    }
}

Is there a library or a good way to automatically do this without having to explicitly write those lines to log?

Glide
  • 20,235
  • 26
  • 86
  • 135
  • `System.out.println`? http://stackoverflow.com/a/407637/2773311 – Arc676 Jan 20 '16 at 01:16
  • How can you pass a custom message without calling a method? You _could_ extend a superclass which does some logging, but this would only fire at the time `super()` is called. – Tim Biegeleisen Jan 20 '16 at 01:21
  • 5
    Perhaps something like [this](http://stackoverflow.com/questions/12732069/how-to-automatically-log-the-entry-exit-of-methods-in-java) could work? – Calvin P. Jan 20 '16 at 01:22
  • @CalvinP. Thanks. That's exactly what I was looking for. – Glide Jan 20 '16 at 18:45

0 Answers0