Developer guide

ArgusLogs logging & data annotations

Use Data Annotations (Attributes) and the ArgusLogs static logger to record method executions and capture manual application telemetries.

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 2 of 4 ArgusLogs.DataAnnotation

Programmatic ArgusLogs

When you need to log specific events or intermediate details inside a method body (not just method entry/exit), use the static helper ArgusLogs.

Why use ArgusLogs?

  • Automatic context enrichment — Fetches the current TraceId from ArgusLogsContext.Current, linking logs to the active web request or thread session.
  • Structured JSON payloads — Pass anonymous objects (object? data) which are serialized as JSON fields in database / Elastic / ClickHouse sinks.
  • No injection required — Static helpers work inside static classes, legacy utilities, or domain models where DI is not configured.

All methods support an optional category parameter (defaults to "App").

1. ArgusLogs.Info

Info
ArgusLogs.Info("User updated profile settings", new { UserId = 45, ChangedFields = new[] { "Email", "Phone" } });

2. ArgusLogs.Debug

Debug
ArgusLogs.Debug("Cache key hit", new { Key = "user_cache_45" });

3. ArgusLogs.Warning

Warning
ArgusLogs.Warning("API response latency was higher than usual", new { LatencyMs = 1250 });

4. ArgusLogs.Error

Error
try
{
    DoRemoteCall();
}
catch (Exception ex)
{
    // Automatically wraps and serializes the exception message and stack trace
    ArgusLogs.Error("Failed to fetch remote inventory data", ex, new { RetriesAttempted = 3 });
}

5. ArgusLogs.Trace

Trace
ArgusLogs.Trace("Releasing database connection back to pool", new { ConnectionId = 849 });