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
ArgusLogs.Info("User updated profile settings", new { UserId = 45, ChangedFields = new[] { "Email", "Phone" } });2. ArgusLogs.Debug
ArgusLogs.Debug("Cache key hit", new { Key = "user_cache_45" });3. ArgusLogs.Warning
ArgusLogs.Warning("API response latency was higher than usual", new { LatencyMs = 1250 });4. ArgusLogs.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
ArgusLogs.Trace("Releasing database connection back to pool", new { ConnectionId = 849 });