Skip to content

HasanJaved-Developer/CentralizedLoggingMonitoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Centralized Logging & Monitoring API

Build codecov Docker Compose CI License Release GHCR api GHCR userapi GHCR web

🐳 Docker Hub Images

Service Pulls Size Version
API Pulls Size Version
User API Pulls Size Version
Web (Portal) Pulls Size Version

A centralized error logging and monitoring API built with .NET 9, Entity Framework Core, and SQL Server. This project is designed to serve as a foundation for collecting, storing, and managing error logs from multiple applications. Phase 5,7&8 have also been complated and the pending Phase 6 will be developed in a new repository.

Each phase of development is preserved in its own branch, culminating in the final Integration Portal, which, together with the API projects, forms a Microservices-inspired architechture that demonstrates the Single Service Database Pattern.


πŸ–₯️ Integration Portal

🌟 What It Is

A .NET 9 MVC Web App that unifies multiple APIs (User Management and Logging) into a single Integration Portal with role-based navigation.


βš™οΈ Implementation Details

  • Login & Validation

    • Custom login (no ASP.NET Core Identity).

    • Client-side validation with jQuery Validation + Bootstrap feedback.

    • Server-side validation ensures username/password check against database seeded users.

    • Bearer handler implemented that fetches token from Memory cache on every request

    • Areas implemented

  • Users & Roles (Alice / Bob)

    • User credentials (alice/alice, bob/bob) seeded in DB/EF Core migration for demo.

    • Alice (Admin) β†’ sees Logs link enabled.

    • Bob (Operations) β†’ restricted, no access to logs.

    • Role checks handled through claims in JWT.

    • JWT is stored in-memory cache

  • Serilog Logging (Web App)

    • Web App configured with Serilog file sinks (/logs/dev-app-.log).

    • Request Audibility and Exception handling middleware added in APIs

    • Structured logs include timestamp, environment, service name, correlation ID.

  • Error Logging API Integration

    • On invalid login β†’ error posted to Error Logging API via secured HTTP client.

    • Uses Polly retry policy for resilience.

    • API persists errors to DB + local log file (from Phase 3).

  • Dynamic Sidebar Category Tree

    • After login β†’ Web App queries User Management API for role/category/module/functions.

    • Sidebar navigation auto-adjust per user role.

  • Logs Link (Working Feature)

    • Clicking Logs fetches data from the Centralized Logging API (Phase 1).

    • Admin users can view structured logs with pagination (DataTables).

    • Non-admins only see authorized links.

  • Logout & Session Handling

    • Logout clears JWT/session cache.

    • User redirected back to login page.

    • Ensures secure re-authentication before accessing APIs again.

  • Testing & CI

    • xUnit unit test covers server-side validation.

    • a WebApplicationFactory-based integration test verifies the login happy path returns 200 OK.

  • Pipeline & Coverage

    • GitHub Actions runs unit tests on push/PR.

    • Collects LCOV via Coverlet.

    • CI/CD (GitHub Actions – Integration & Delivery), Latest Tag, Codecov, and GHCR/Docker Hub (Pulls & Version) are displayed above.


πŸ“Š Architecture Glimpse

Integration Portal Architecture
View Mermaid source


πŸ“Έ Screenshots

πŸ”‘ Login Page

Login Page

πŸ“‚ Home & Sidebar

Sidebar Tree

πŸ“Š Logs (Admin View)

Logs Page

πŸ“‘ API Swagger UI

User Management API

User API Swagger

Centralized Error Logging API

Logging API Swagger


πŸ—οΈ Planned Enhancements (Next Repository)

The next repository will focus on:

  • Centralized Authorization Layer/Handler

    • Area/Controller/Action logic stored in DB.

    • Raised to in-memory cache for performance.

    • Shared distributed cache layer (Dragonfly/Redis).

  • Cross-API Authorization Consistency

    • One source of truth for both Web App + APIs.

    • Cache synchronization across services.


πŸ“‚ Project Structure

IntegrationPortal/
 β”œβ”€β”€ Areas/
 β”‚ β”œβ”€β”€ User/ # User-related features
 β”‚ β”‚ β”œβ”€β”€ Controllers/ # Controllers for User area
 β”‚ β”‚ β”œβ”€β”€ Models/ # EF Core models
 β”‚ β”‚ └── Views/ # Razor views
 β”‚ β”œβ”€β”€ Admin/ # Admin-related features
 β”‚ β”‚ β”œβ”€β”€ Controllers/
 β”‚ β”‚ β”œβ”€β”€ Models/
 β”‚ β”‚ └── Views/
 β”‚ └── ... # Other areas (modules, roles, etc.)
 β”œβ”€β”€ Services/ # Shared services & API clients
 β”œβ”€β”€ wwwroot/ # Static assets (CSS, JS, icons)
 β”œβ”€β”€ appsettings.json # Config (logging, connection, JWT)
 β”œβ”€β”€ docs/
 β”‚ └── integration_portal_architecture.png
 β”‚ └── integration_portal_architecture.mmd
 └── README.md # Documentation

βš™οΈ Environments

The project supports multiple environments:

  • Development

    • Connection string uses local SQL Server (LocalDB).
    • Loaded from appsettings.Development.json.
  • Production

    • Connection string points to Docker SQL Server.

    • Loaded from appsettings.Production.json.

    • Environment set via:

      ASPNETCORE_ENVIRONMENT=Production

πŸ–₯️ Running with Visual Studio (Development)

Open CentralizedLoggingMonitoring.sln in Visual Studio.

Press F5 or run the project.

By default, it uses Development environment with appsettings.Development.json.


πŸ“¦ Running with Docker (Production)

  • Build and start the containers

    • docker-compose up --build
  • Stop the containers

    • docker-compose down

The services will be available at:

[web app] HTTP β†’ http://localhost:7000

[user management api] HTTP β†’ http://localhost:6000/api

[error log api] HTTP β†’ http://localhost:5000/api

(HTTPS optional, future phase)


πŸ“ˆ Future Enhancements

πŸ› Phase 6: Info Express API with Client

  • Add SQL and SQL count in database of a report ABC
  • Add Parameter JSON in database of a report ABC
  • Add Datatable Header JSON in database of a report ABC
  • Update Seed Data
  • Create a form ABC to search and download without writing code

This will be developed as a new repository.


πŸ“¬ Sample API Requests

Create Application

http POST /api/Applications
Content-Type: application/json

{
  "name": "Payment Service",
  "environment": "Production"
}

Create Error Log

http POST /api/ErrorLogs
Content-Type: application/json

{
  "applicationId": 1,
  "severity": "Error",
  "message": "Null reference exception in payment processing",
  "stackTrace": "at PaymentService.Process()...",
  "source": "PaymentService",
  "userId": "user123",
  "requestId": "req-456"
}

🀝 Contributing

Future phases will be added in branches (phase-2, phase-3, …). Main branch will always contain the latest stable version.

Contributions are welcome β€” whether bug fixes, feature enhancements, or discussions about authorization best practices.


πŸ“‚ Repository Roadmap

phase-1-core-api β†’ Completed Phase 1.
phase-2-logging β†’ Planned logging integration.
phase-3-um-api β†’ Planned API documentation.
main β†’ Always up to date with the latest stable phase.

πŸ“œ License

This project is licensed under the MIT License.


About

Centralized Logging & Monitoring API (Core API, User API, Integration Portal with SQL Server & Docker).

Topics

Resources

License

Stars

Watchers

Forks

Packages