SmooAI.Logger 4.1.3

dotnet add package SmooAI.Logger --version 4.1.3
                    
NuGet\Install-Package SmooAI.Logger -Version 4.1.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SmooAI.Logger" Version="4.1.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SmooAI.Logger" Version="4.1.3" />
                    
Directory.Packages.props
<PackageReference Include="SmooAI.Logger" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SmooAI.Logger --version 4.1.3
                    
#r "nuget: SmooAI.Logger, 4.1.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SmooAI.Logger@4.1.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SmooAI.Logger&version=4.1.3
                    
Install as a Cake Addin
#tool nuget:?package=SmooAI.Logger&version=4.1.3
                    
Install as a Cake Tool

SmooAI.Logger

NuGet License: MIT

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 correlationId flows 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 a User, HttpRequest, or HttpResponse and 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 any ILogger sink 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

License

MIT — © SmooAI

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.1.3 100 4/24/2026
0.1.0 102 4/24/2026