Logging with Spring AOP and Custom Annotations In JAVA Application

25 / Jul / 2016 by Stayendra Verma 0 comments

Whenever i am working on development of any application I want to log every execution of a method, seeing what arguments it receives, what it returns for easy debugging and how much time every execution take.

So we have created a utility based on Spring AOP and here we will see how we can use it in our projects.

public class HomeController {



The @Loggable annotation have option to log method parameter and results. By default both option are true you can disable these option by setting attributes.

@Loggable(params = true,result = false)

We can override options at method level or Can mark only selected methods for logging.

@Loggable(result = false)
public Integer multiply(int a, int b) {
Integer res = a * b;
return res;

Note: Don’t forget to set your application log level from application configuration file.


//gradle dependency

download project form github and copy log package and paste into your project.


Leave a Reply

Your email address will not be published. Required fields are marked *