Developer guide

Deep dive into ArgusLogs.core

Developer guide for ArgusLogs—the production debugging and observability platform for .NET applications.

Tutorials are hands-on walkthroughs (prerequisites, install, configuration, code, expected result, explanation, then next steps). Official reference stays in documentation — this is not a full docs clone.

Section 6 of 6 ArgusLogs.core

Fluent example

A full configuration illustrating how to combine these settings using the fluent options builder:

Program.cs — fluent ArgusLogsOptions
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);
        });
    });
});