This project is a reusable Spring Boot AOP-based logging and method profiling library that provides a custom annotation @LogExecution to automatically log method entry, exit, arguments, return values, exceptions, and execution time.
- Simple
@LogExecutionannotation for any method - Logs:
- Method execution time
- Request arguments (optional)
- Response values (optional)
- Exceptions (if thrown)
- Configurable log level:
info,debug - Includes unit tests
- Can be packaged as a reusable JAR in other Spring Boot apps
@LogExecution(logRequestArguments = true, logResponseArguments = true, debugLevel = "info")
public String processSomething(String input) {
// your logic
return "done";
}INFO - Method entry: com.ms.service.OrderService:processOrder:[12345]
INFO - Method exit: com.ms.service.OrderService:processOrder:Processed
INFO - com.ms.service.OrderService:processOrder execution completed in: 38 ms
INFO - Method entry: com.ms.service.PaymentService:chargeCard:[null]
ERROR - Exception occurred at: com.ms.service.PaymentService:chargeCard:Card number cannot be null
- Uses
@Aroundadvice inLogAspect - Reads metadata from
@LogExecution - Logs input/output conditionally
- Handles exceptions via
@AfterThrowing
git clone https://github.com/rutu-y-patel/spring-aop-custom-annotation.git
cd spring-aop-custom-annotation
mvn testmvn clean install<dependency>
<groupId>com.ms</groupId>
<artifactId>logging-aspect</artifactId>
<version>1.0.7</version>
</dependency>- Java 8+
- Spring Boot 2.7.x
- Spring AOP
- Maven
src/
├── main/java/com/ms/aspect/logging/
│ ├── LogExecution.java
│ ├── LogAspect.java
│ └── LogExecutionConfig.java
├── resources/META-INF/
│ └── spring.factories
├── test/
│ └── (unit tests)
This library can also be used as a lightweight method profiler in Spring Boot projects.
It is helpful if you're searching for:
- Spring Boot custom annotation
- Spring AOP logging
- Log method execution time in Java
- Reusable AOP logging library
- Custom annotation logger
- Spring Boot aspect logging
- Java method profiling with AOP
This project is licensed under the MIT License.
Use it freely in your projects with proper attribution.