InsightLogger is a Spring Core + Spring AOP project designed to demonstrate real-world usage of Aspect-Oriented Programming (AOP) for logging, performance measurement, and runtime metrics aggregation. It operates entirely at the core level—no web layer or REST endpoints—focusing purely on cross-cutting concerns like logging, performance tracking, and error monitoring.
The project serves as a capstone implementation for the Spring AOP module, built to simulate enterprise-style logging and metrics functionality within a clean, lightweight architecture.
- Annotation-driven logging via
@Loggable - Automatic execution time measurement using
@Aroundadvice - Exception tracking using
@AfterThrowingadvice - Centralized metrics collection with in-memory registry (
MetricsRegistry) - Aggregated performance reporting through
MetricsReporter - Thread-safe design for concurrent method calls
- Console-based output (no external dependencies)
com.chandra.insightlogger
├── annotation/
│ └── Loggable.java → Custom annotation for AOP interception
├── aspect/
│ └── LoggingAspect.java → Core AOP class handling logging and metrics updates
├── metrics/
│ ├── MethodMetrics.java → Data model for per-method statistics
│ ├── MetricsRegistry.java → Thread-safe registry managing all metrics
│ └── MetricsReporter.java → Prints aggregated metrics report to console
├── service/
│ └── SampleService.java → Demonstration service with @Loggable methods
└── InsightLoggerApplication.java → Entry point triggering demo execution
This project demonstrates how to:
- Use Spring AOP to intercept method calls dynamically.
- Build custom annotations to control aspect behavior.
- Design and integrate cross-cutting concerns without polluting business logic.
- Collect and aggregate runtime metrics programmatically.
- Structure a Spring Core-only application (no MVC or REST).
[LOG] Entering: com.chandra.insightlogger.service.SampleService.performTask | Args: []
[LOG] Exiting: com.chandra.insightlogger.service.SampleService.performTask | Execution Time: 112 ms | Result: void
[LOG] Entering: com.chandra.insightlogger.service.SampleService.calculateSum | Args: [5, 10]
[LOG] Exiting: com.chandra.insightlogger.service.SampleService.calculateSum | Execution Time: 3 ms | Result: 15
[LOG] Exception in: com.chandra.insightlogger.service.SampleService.simulateError
[LOG] Exception Type: RuntimeException | Message: Simulated error
[APP] Handled simulated error gracefully: Simulated error
========== Metrics Report ==========
Method: com.chandra.insightlogger.service.SampleService.performTask | Calls: 1 | Errors: 0 | Avg Time: 112.0 ms
Method: com.chandra.insightlogger.service.SampleService.calculateSum | Calls: 1 | Errors: 0 | Avg Time: 3.0 ms
Method: com.chandra.insightlogger.service.SampleService.simulateError | Calls: 0 | Errors: 1 | Avg Time: 0.0 ms
====================================
| Layer | Technology |
|---|---|
| Language | Java 21 |
| Framework | Spring Boot 3.x |
| Core Modules | Spring Context, Spring AOP |
| Build Tool | Maven |
| Logging Output | Console |
@Loggableannotation marks methods to be intercepted.LoggingAspectintercepts these methods using@Aroundand@AfterThrowingadvices.- Execution time, result, and exception data are logged to console.
MetricsRegistryupdates metrics after each method run.MetricsReporterprints an aggregated summary report to console.
- Project Name:
insight-logger - Module Scope: Spring Core + Spring AOP only (no REST / MVC)
- Primary Purpose: Demonstrate real-world AOP use case for logging and metrics aggregation.
- Deep understanding of AOP join points, advices, and pointcuts.
- How to design annotation-driven aspects cleanly.
- Handling exceptions, method metadata, and performance data centrally.
- Building framework-style reusable components in Spring.
feat: initialize Spring Boot project for InsightLogger (Core + AOP only)feat: add @Loggable annotation to mark methods for AOP-based loggingfeat: implement execution time measurement and structured method loggingfeat: integrate MetricsRegistry and MetricsReporter for performance aggregationdemo: integrate SampleService demonstration and validate end-to-end flow