Skip to content

InsightLogger – AOP-based Logging & Metrics Framework (Spring Core + AOP) A lightweight, console-based Spring Boot project demonstrating real-world use of Spring AOP for centralized logging, performance measurement, and runtime metrics tracking. Built entirely with Spring Core and AOP, it features annotation-driven logging, execution time analysis,

Notifications You must be signed in to change notification settings

codeWithVCS/InsightLogger-AOP-based-Centralized-Logging-and-Metrics-Framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

InsightLogger – AOP-based Centralized Logging and Metrics Framework

📊 Project Overview

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.


🔍 Key Features

  • Annotation-driven logging via @Loggable
  • Automatic execution time measurement using @Around advice
  • Exception tracking using @AfterThrowing advice
  • 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)

🔧 Architecture Overview

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

🎓 Learning Objectives

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).

🔊 Console Output Example

Example Run

[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
====================================

🛠️ Technologies Used

Layer Technology
Language Java 21
Framework Spring Boot 3.x
Core Modules Spring Context, Spring AOP
Build Tool Maven
Logging Output Console

🔄 Execution Flow

  1. @Loggable annotation marks methods to be intercepted.
  2. LoggingAspect intercepts these methods using @Around and @AfterThrowing advices.
  3. Execution time, result, and exception data are logged to console.
  4. MetricsRegistry updates metrics after each method run.
  5. MetricsReporter prints an aggregated summary report to console.

👩‍💻 Author

Chandra Sekhar Java Backend Developer

🔗 Repository Information

  • 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.

📚 Learning Takeaways

  • 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.

📦 Sample Commit History (Milestones)

  • feat: initialize Spring Boot project for InsightLogger (Core + AOP only)
  • feat: add @Loggable annotation to mark methods for AOP-based logging
  • feat: implement execution time measurement and structured method logging
  • feat: integrate MetricsRegistry and MetricsReporter for performance aggregation
  • demo: integrate SampleService demonstration and validate end-to-end flow

About

InsightLogger – AOP-based Logging & Metrics Framework (Spring Core + AOP) A lightweight, console-based Spring Boot project demonstrating real-world use of Spring AOP for centralized logging, performance measurement, and runtime metrics tracking. Built entirely with Spring Core and AOP, it features annotation-driven logging, execution time analysis,

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages