dotnet add package AsGuard
dotnet add package AsGuard
dotnet add package AsGuard
using AsGuard.Extensions;
using AsGuard.Domain.RequestLogging; var builder = WebApplication.CreateBuilder(args); builder.Services.AddRequestLogging(options =>
{ options.DatabaseProvider = LoggingDatabaseProvider.Sqlite; options.ConnectionString = "Data Source=asguard.db"; options.DashboardRoute = "/logs"; options.DashboardUsername = builder.Configuration["AsGuard:Username"] ?? "admin"; options.DashboardPassword = builder.Configuration["AsGuard:Password"] ?? "change-me"; options.EnableExceptionLogging = true; options.CaptureHostLogs = true;
}); var app = builder.Build();
using AsGuard.Extensions;
using AsGuard.Domain.RequestLogging; var builder = WebApplication.CreateBuilder(args); builder.Services.AddRequestLogging(options =>
{ options.DatabaseProvider = LoggingDatabaseProvider.Sqlite; options.ConnectionString = "Data Source=asguard.db"; options.DashboardRoute = "/logs"; options.DashboardUsername = builder.Configuration["AsGuard:Username"] ?? "admin"; options.DashboardPassword = builder.Configuration["AsGuard:Password"] ?? "change-me"; options.EnableExceptionLogging = true; options.CaptureHostLogs = true;
}); var app = builder.Build();
using AsGuard.Extensions;
using AsGuard.Domain.RequestLogging; var builder = WebApplication.CreateBuilder(args); builder.Services.AddRequestLogging(options =>
{ options.DatabaseProvider = LoggingDatabaseProvider.Sqlite; options.ConnectionString = "Data Source=asguard.db"; options.DashboardRoute = "/logs"; options.DashboardUsername = builder.Configuration["AsGuard:Username"] ?? "admin"; options.DashboardPassword = builder.Configuration["AsGuard:Password"] ?? "change-me"; options.EnableExceptionLogging = true; options.CaptureHostLogs = true;
}); var app = builder.Build();
app.UseHttpsRedirection(); app.UseRequestLogging(); // ← right here app.UseAuthentication();
app.UseAuthorization();
app.MapControllers(); app.Run();
app.UseHttpsRedirection(); app.UseRequestLogging(); // ← right here app.UseAuthentication();
app.UseAuthorization();
app.MapControllers(); app.Run();
app.UseHttpsRedirection(); app.UseRequestLogging(); // ← right here app.UseAuthentication();
app.UseAuthorization();
app.MapControllers(); app.Run();
https://localhost:<port>/logs
https://localhost:<port>/logs
https://localhost:<port>/logs
[HTTP Request In] │ ▼
┌──────────────────────┐
│ Exception Handler │ ← register first so AsGuard can intercept exceptions
└──────────┬───────────┘ │ ▼
┌──────────────────────┐
│ HTTPS / CORS / HSTS │
└──────────┬───────────┘ │ ▼
┌──────────────────────┐
│ UseRequestLogging() │ ← HERE: correlation IDs generated, body stream opened
└──────────┬───────────┘ │ ▼
┌──────────────────────┐
│ Auth & Authorization│ ← 401s and 403s will still be logged
└──────────┬───────────┘ │ ▼
┌──────────────────────┐
│ Your Endpoints │
└──────────────────────┘
[HTTP Request In] │ ▼
┌──────────────────────┐
│ Exception Handler │ ← register first so AsGuard can intercept exceptions
└──────────┬───────────┘ │ ▼
┌──────────────────────┐
│ HTTPS / CORS / HSTS │
└──────────┬───────────┘ │ ▼
┌──────────────────────┐
│ UseRequestLogging() │ ← HERE: correlation IDs generated, body stream opened
└──────────┬───────────┘ │ ▼
┌──────────────────────┐
│ Auth & Authorization│ ← 401s and 403s will still be logged
└──────────┬───────────┘ │ ▼
┌──────────────────────┐
│ Your Endpoints │
└──────────────────────┘
[HTTP Request In] │ ▼
┌──────────────────────┐
│ Exception Handler │ ← register first so AsGuard can intercept exceptions
└──────────┬───────────┘ │ ▼
┌──────────────────────┐
│ HTTPS / CORS / HSTS │
└──────────┬───────────┘ │ ▼
┌──────────────────────┐
│ UseRequestLogging() │ ← HERE: correlation IDs generated, body stream opened
└──────────┬───────────┘ │ ▼
┌──────────────────────┐
│ Auth & Authorization│ ← 401s and 403s will still be logged
└──────────┬───────────┘ │ ▼
┌──────────────────────┐
│ Your Endpoints │
└──────────────────────┘
// PostgreSQL
options.DatabaseProvider = LoggingDatabaseProvider.PostgreSql;
options.ConnectionString = "Host=localhost;Database=asguard;Username=postgres;Password=pass"; // In-Memory (no persistence, great for tests)
options.DatabaseProvider = LoggingDatabaseProvider.InMemory;
options.MaxInMemoryEntries = 10000;
// PostgreSQL
options.DatabaseProvider = LoggingDatabaseProvider.PostgreSql;
options.ConnectionString = "Host=localhost;Database=asguard;Username=postgres;Password=pass"; // In-Memory (no persistence, great for tests)
options.DatabaseProvider = LoggingDatabaseProvider.InMemory;
options.MaxInMemoryEntries = 10000;
// PostgreSQL
options.DatabaseProvider = LoggingDatabaseProvider.PostgreSql;
options.ConnectionString = "Host=localhost;Database=asguard;Username=postgres;Password=pass"; // In-Memory (no persistence, great for tests)
options.DatabaseProvider = LoggingDatabaseProvider.InMemory;
options.MaxInMemoryEntries = 10000;
public class LoginRequest
{ public string Username { get; set; } [AsGuardMasked] public string Password { get; set; } // stored as "[REDACTED]"
}
public class LoginRequest
{ public string Username { get; set; } [AsGuardMasked] public string Password { get; set; } // stored as "[REDACTED]"
}
public class LoginRequest
{ public string Username { get; set; } [AsGuardMasked] public string Password { get; set; } // stored as "[REDACTED]"
}
options.SensitiveBodyKeys.Add("creditCardNumber");
options.SensitiveBodyKeys.Add("ssn");
options.SensitiveBodyKeys.Add("token");
options.SensitiveBodyKeys.Add("creditCardNumber");
options.SensitiveBodyKeys.Add("ssn");
options.SensitiveBodyKeys.Add("token");
options.SensitiveBodyKeys.Add("creditCardNumber");
options.SensitiveBodyKeys.Add("ssn");
options.SensitiveBodyKeys.Add("token");
# environment variable approach
ASGUARD__USERNAME=your_secure_user
ASGUARD__PASSWORD=your_secure_password
# environment variable approach
ASGUARD__USERNAME=your_secure_user
ASGUARD__PASSWORD=your_secure_password
# environment variable approach
ASGUARD__USERNAME=your_secure_user
ASGUARD__PASSWORD=your_secure_password
options.RetentionDays = 30;
options.RetentionDays = 30;
options.RetentionDays = 30; - Full HTTP request/response logging with timing, method, status, and body capture
- Exception tracking with stack traces, severity, and trends — no Sentry account required
- Host ILogger capture — your existing LogWarning and LogError calls get stored and searchable
- A built-in live dashboard with dark/light mode, SSE-powered real-time updates, and filtering
- APM trace timelines — auto-tracks EF Core queries and HttpClient calls with Gantt charts
- Alerting for queue pressure, exception spikes, and persistence failures
- Sensitive data masking via [AsGuardMasked] attributes and configurable header redaction - SQLite — zero setup, file-based; perfect for local dev, small apps, and quick demos
- SQL Server — the natural fit for production on Azure or Windows-hosted workloads
- PostgreSQL — ideal for Linux environments and cloud-native stacks
- In-Memory — no persistence, no config; great for integration tests and ephemeral environments