java - How to log Spring Data JPA repository method execution time? -


i have simple spring data jpa repository.

public interface userrepository extends jparepository<userentity, serializable>{ … } 

is there way monitor execution time methods generated spring (for example findone(…))?

the easiest way use customizabletraceinterceptor follows:

@configuration @enableaspectjautoproxy public class springdataexecutionloggingconfiguration {    @bean   public customizabletraceinterceptor customizabletraceinterceptor() {      customizabletraceinterceptor customizabletraceinterceptor = new customizabletraceinterceptor();     customizabletraceinterceptor.setusedynamiclogger(true);     customizabletraceinterceptor.setexitmessage("executed $[methodname] in $[invocationtime]");     return customizabletraceinterceptor;   }    @bean   public advisor advisor() {      aspectjexpressionpointcut pointcut = new aspectjexpressionpointcut();     pointcut.setexpression("execution(public * org.springframework.data.jpa.repository.crudrepository+.*(..))");     return new defaultpointcutadvisor(pointcut, customizabletraceinterceptor());   } } 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -