SmooAI.Logger
4.1.3
dotnet add package SmooAI.Logger --version 4.1.3
NuGet\Install-Package SmooAI.Logger -Version 4.1.3
<PackageReference Include="SmooAI.Logger" Version="4.1.3" />
<PackageVersion Include="SmooAI.Logger" Version="4.1.3" />
<PackageReference Include="SmooAI.Logger" />
paket add SmooAI.Logger --version 4.1.3
#r "nuget: SmooAI.Logger, 4.1.3"
#:package SmooAI.Logger@4.1.3
#addin nuget:?package=SmooAI.Logger&version=4.1.3
#tool nuget:?package=SmooAI.Logger&version=4.1.3
SmooAI.Logger
Structured logs for .NET that carry the full story — correlation IDs, request + response, user, and caller location on every line.
.NET port of @smooai/logger. Drop it into a Lambda, ECS service, or worker and every log entry tells you where it fired, who triggered it, and which request it belonged to — without threading context through every method. JSON lines that land in CloudWatch, Datadog, or any ILogger sink, and wire-compatible with the TypeScript, Python, Go, and Rust ports.
Install
dotnet add package SmooAI.Logger
What you get
- Correlation across services — a single
correlationIdflows through HTTP calls, SQS records, and background tasks so you can grep one ID and see the whole request. - Typed user + request + response fields — no more stringly-typed
["user_id"] = user.Id. Push aUser,HttpRequest, orHttpResponseand the logger serializes every relevant field. - Exact caller location — every line carries file + method + line number. No more hunting for which service logged what.
- Structured by default — strict JSON lines in production, ANSI pretty-print locally.
- Wire-compatible with every other SmooAI.Logger port — the schema is the same in TS, Python, Go, and Rust, so distributed traces stitch together across language boundaries.
- Works with
Microsoft.Extensions.Logging— forward to Serilog, AWS.Logger, or anyILoggersink without losing structure.
Quick start
using SmooAI.Logger;
var log = new SmooLogger(new SmooLoggerOptions
{
Name = "api",
InitialContext = new Dictionary<string, object?>
{
["service"] = "checkout-api",
["stage"] = "production",
},
});
log.LogInfo("Order placed", new { orderId = "ord_123", userId = "u_456", total = 42.00m });
Output (CloudWatch-friendly JSON line):
{
"level": "info",
"name": "api",
"time": "2026-04-23T12:34:56.789Z",
"correlationId": "6b4e…",
"requestId": "6b4e…",
"service": "checkout-api",
"stage": "production",
"msg": "Order placed",
"orderId": "ord_123",
"userId": "u_456",
"total": 42.0
}
Track a request end-to-end
// Correlation IDs thread through your system automatically
log.SetCorrelationId(Request.Headers["X-Correlation-Id"]);
log.SetUser(new User { Id = user.Id, Role = user.Role });
log.SetRequestContext(Request);
try
{
var order = await CreateOrderAsync(dto);
log.LogInfo("Order created", new { orderId = order.Id });
return Ok(order);
}
catch (Exception ex)
{
// Error logs carry the full context: correlation ID, user, request, stack
log.LogError("Order creation failed", ex);
throw;
}
Scopes and correlation
using (log.BeginScope(new Dictionary<string, object?> { ["requestId"] = "req_789" }))
{
log.LogWarning("Retrying upstream call", new { attempt = 2 });
// every log inside the scope carries requestId=req_789 on top of the base context
}
BeginScope is thread-safe — concurrent LogInfo calls inside the same scope don't step on each other.
Forwarding to Microsoft.Extensions.Logging
Wire the SmooLogger to an upstream ILogger (Serilog, AWS.Logger, or whatever your org is standardized on) and every structured field rides through as a scope so downstream sinks still see the full story.
using Microsoft.Extensions.Logging;
var factory = LoggerFactory.Create(b => b.AddSerilog());
var log = new SmooLogger(new SmooLoggerOptions
{
Name = "api",
ForwardTo = factory.CreateLogger("SmooAI.Logger"),
});
log.LogError("Upstream timeout", new Exception("connect timed out"),
new { upstream = "stripe", timeoutMs = 3000 });
The SmooLogger still emits JSON to stdout and forwards the structured payload as a scope to Serilog — downstream sinks receive every field as a first-class property, not a string blob.
Environment
| Variable | Values | Default | Effect |
|---|---|---|---|
LOG_LEVEL |
trace debug info warn error fatal |
info |
Minimum level emitted |
IS_LOCAL, SST_DEV, GITHUB_ACTIONS |
"true" |
— | Enables pretty-print |
Related
@smooai/logger— TypeScript / Nodesmooai-logger— Pythonsmooai-logger— Rustgithub.com/SmooAI/logger/go— Go
License
MIT — © SmooAI
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.