While comparing the run of my wizard and a similar standard one, I have to check all entrances into all functions for both cases. Is there some tool that can automate the process? I can't do it by simply inserting the log lines in code, because 98% of the process run inside the code of library functions. Can the java machine catch every entrance or leave in/out of every method and log it somewhere?

  • 1
    this can be done with aspect oriented programming. I think it is more likely to get an answer for this question if the question is migrated to stackoverflow.com
    – k3b
    May 25, 2012 at 9:53
  • 1
    Maybe. But on SO a question without code is considered as a one of worse quality. As for "programmers", there when I asked on testing problems, was readdressed here, too. Aspect works with my code only, not libraries, doesn't it?
    – Gangnus
    May 25, 2012 at 10:01
  • 1
    I don't think your assessment of a question without code is considered worse quality is accurate, personally. Worse quality would be questions without context. Code easily provides context, but you've managed to provide plenty of context in your question. Not that this question isn't also appropriate here, but I think it would be just fine there too.
    – corsiKa
    May 25, 2012 at 17:27
  • 1
    What is your ultimate goal? Do you need to be informed when your method is called in a real time? Or to count how many times the method is invoked during a certain usage session? Or maybe you need performance measurement / stress testing? Depending on your needs, there may be different approaches. Jun 9, 2012 at 4:11

2 Answers 2


With Aspect Oriented Programming, you can use an annotation which executes Before (entering), After, or Around (before and after) a method. There isn't anything specifically designed to execute when entering a method, unless you used @After.

For more information regarding the syntax and options, here is a link to Spring's online documentation: http://static.springsource.org/spring/docs/2.0.x/reference/aop.html


You can use @Loggable annotation from jcabi-aspects, which wraps all methods you want to debug with a simple logging mechanism:

public String load(URL url) {
  return url.openConnection().getContent();

It logs through SLF4J.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.