How to log the time taken by methods in Springframework?

前端 未结 5 1740
时光说笑
时光说笑 2021-01-31 06:20

Is it possible in springframework to log the time taken by methods [ selective | all ] automatically. By automatically i mean, i don\'t want to go to each method and write the l

5条回答
  •  我在风中等你
    2021-01-31 07:23

    I see that there has already been an accepted answer here, but I'd encourage everyone to take a look at the latest release of Spring Toolsuite (SpringSource's distro of Eclipse). It comes with a profiling utility out of the box, Spring Insight, that provides these exact statistics at runtime in a nice format. Just deploy your app to its internal tomcat, hit a few pages, then go to the /insight servlet and see the time taken in each method called all the way down to the SQL statements that were executed and how long they took.

    Here's a link to a nice writeup about Spring Insight that should get you what you want in just a few minutes. http://www.dotkam.com/2009/10/28/spring-insight-in-action-5-minutes-from-scratch/

提交回复
热议问题