DEV Community

Cover image for ASP.NET Core Request & Exception Logging with a Built-In Dashboard
Mahmood Al Sarraj
Mahmood Al Sarraj

Posted on

ASP.NET Core Request & Exception Logging with a Built-In Dashboard

Most ASP.NET Core logging setups tell you that something failed — but not what actually happened during the request lifecycle.

I built AsGuard to provide lightweight request + exception logging with a built-in dashboard and minimal setup.

GitHub Repository:
https://github.com/mahmood-alsarraj/asguard

Why AsGuard?

  • centralized request + exception visibility
  • built-in dashboard
  • minimal setup
  • easier inspection during debugging
  • lightweight integration
Feature Description
🚀 Queue-based persistence Non-blocking async writes - your API never waits for database
📊 Built-in dashboard Beautiful Razor UI with dark/light mode and live updates
🔒 Sensitive data masking [AsGuardMasked] attribute + configurable header redaction
📝 Body capture Request/response bodies with content-type allowlist
🔗 Correlation IDs Distributed tracing with configurable headers (default: X-Correlation-ID)
Live SSE updates Real-time push notifications without SignalR
🗄️ Multiple databases SQL Server, PostgreSQL, SQLite, or In-Memory
📈 Exception analytics Trends, severity summaries, and configurable alerts
🎯 Host ILogger capture Automatically captures ILogger<T> warnings/errors
🔔 Alerting system Queue pressure, exception spikes, persistence failures
📡 REST API Full programmatic access to logs and stats
🧹 Retention policies Auto-cleanup with configurable intervals

Quick Setup

dotnet add package AsGuard
builder.Services.AddRequestLogging(options =>
{
    options.DatabaseProvider = LoggingDatabaseProvider.Sqlite;
    options.ConnectionString = "Data Source=AsGuard.db";
    options.DashboardRoute = "/request-logs-ui";
    options.DashboardUsername = "admin";
    options.DashboardPassword = "admin123";
    options.EnableExceptionLogging = true;
    options.LogRequestBody = true;
    options.LogResponseBody = true;    
});

var app = builder.Build();

app.UseExceptionHandler("/error");
// After the exception handler
app.UseRequestLogging();
Enter fullscreen mode Exit fullscreen mode

Navigate to "/request-logs-ui", enter your credentials, and watch your application’s heartbeat in real-time.

Final Thoughts

Modern applications need visibility.

Sometimes you don’t need a massive observability platform — you just need a fast and practical way to inspect requests and exceptions.

That’s the problem AsGuard aims to solve for ASP.NET Core developers.

Resources:

⭐ Star the repo if AsGuard helps you!

Top comments (0)