Section 6 of 6 ArgusLogs.core
Fluent example
A full configuration illustrating how to combine these settings using the fluent options builder:
builder.Services.AddArgusLogsLogging(builder.Configuration, options =>
{
// --- Output: where logs go + how they look ---
options.WithLogFile("logs/app-telemetry.json") // File sink path (structured telemetry file)
.WithLogFileNameFormat("_yyyyMMdd") // Rotate daily: app-telemetry_20260730.json
.WithBeautiful(true) // Pretty-print JSON for easier local debugging
.WithMinimumLogLevel(ArgusLogs.Logging.LogLevel.Debug); // Keep Debug+ (verbose in dev)
options.WriteToFile() // Persist events to the configured log file
.WriteToConsole(); // Also mirror to stdout (handy in Docker / local runs)
// --- Licensing: unlock capabilities (online verify is built into ArgusLogs.core) ---
options.SetLicense("ARGUS-LIC-993-293-1002");
// --- Database tracker: what SQL ArgusLogs should capture ---
options.WithDatabase(db =>
{
db.WithLogResultRows(false) // Don't dump row payloads (avoid PII / huge logs in prod)
.WithFilterInternalQueries(true) // Skip EF health/migration noise
.SetMaxResultRows(50); // Hard cap if result logging is ever enabled
});
// --- Network tracker: request / response / user correlation ---
options.WithNetworkTracking(net =>
{
net.WithRequest(req =>
{
req.WithLogBody(true) // Capture request body (uses buffering)
.WithLogHeaders(true) // Include headers for forensics
.WithLogCookies(false) // Skip cookies (often sensitive / noisy)
.WithTraceIdSelector(ctx => // Prefer inbound custom header for distributed tracing
ctx.Request.Headers["X-Custom-Trace"].ToString()
?? Guid.NewGuid().ToString()); // Fallback: generate a new correlation id
});
net.WithResponse(res =>
{
res.WithLogBody(true) // Capture response payload for debugging APIs
.WithLogStatusCode(true); // Always record 2xx / 4xx / 5xx
});
net.WithUser(usr =>
{
usr.WithLogRoles(true) // Attach roles for authz debugging
.WithUserIdSelector(ctx => // Map your tenant claim instead of default NameIdentifier
ctx.User?.FindFirst("tenant_user_id")?.Value);
});
});
});