AxisLogger 2.2.0
dotnet add package AxisLogger --version 2.2.0
NuGet\Install-Package AxisLogger -Version 2.2.0
<PackageReference Include="AxisLogger" Version="2.2.0" />
<PackageVersion Include="AxisLogger" Version="2.2.0" />
<PackageReference Include="AxisLogger" />
paket add AxisLogger --version 2.2.0
#r "nuget: AxisLogger, 2.2.0"
#:package AxisLogger@2.2.0
#addin nuget:?package=AxisLogger&version=2.2.0
#tool nuget:?package=AxisLogger&version=2.2.0
AxisLogger — Documentation
Request-scoped structured logging for C# — IAxisLogger<T> wraps Microsoft.Extensions.Logging's ILogger<T> and auto-enriches every entry with the ambient OriginId, TraceId and JourneyId pulled from the current IAxisMediator. Plus LogResult(tag, AxisResult) for one-line structured logging of every railway outcome, and an opt-in LoggingBehavior that logs each mediator request automatically.
public class CreatePersonHandler(IAxisLogger<CreatePersonHandler> logger, ...)
{
public Task<AxisResult<CreatePersonResponse>> HandleAsync(CreatePersonCommand cmd)
{
logger.LogInformation("Creating person", ("Document", cmd.Document));
return factory.CreateAsync(cmd)
.ThenAsync(person => uow.SaveChangesAsync())
.TapAsync(r => logger.LogResult("CreatePerson", r)) // one line, structured outcome
.MapAsync(_ => new CreatePersonResponse { PersonId = cmd.PersonId });
}
}
Use this page as a map: read the trunk below (~5 min) and jump straight to the detail of the group you need — without reading hundreds of lines.
The trunk (read first)
The interface in 60 seconds
public interface IAxisLogger<in T>
{
void LogDebug(string message, params (string Key, object? Value)[] properties);
void LogInformation(string message, params (string Key, object? Value)[] properties);
void LogWarning(string message, params (string Key, object? Value)[] properties);
void LogError(string message, params (string Key, object? Value)[] properties);
void LogError(Exception exception, string message, params (string Key, object? Value)[] properties);
void LogCritical(string message, params (string Key, object? Value)[] properties);
void LogResult(string tag, AxisResult result);
}
Six familiar levels, every overload takes params (string Key, object? Value)[] properties for structured log enrichment. Every entry is wrapped in an ILogger.BeginScope(...) carrying UtcTime, OriginId, TraceId, JourneyId and your properties. → The IAxisLogger<T> contract
Why a generic? — IAxisLogger<T>
The T is the category for Microsoft.Extensions.Logging (same role as ILogger<T>). It tags the log entry's source so filters and sinks can route by class. → Categories and structured properties
LogResult — the railway companion
logger.LogResult("CreatePerson", result);
Success → Information + Tag/RequestName. Failure → Error + the same plus AxisErrorList. One call, one structured entry, the right level. → LogResult — structured outcomes
LoggingBehavior — log every request automatically
Opt-in mediator behaviour that logs Handling {RequestName} at the top of every handler:
services
.AddAxisLogger()
.AddLoggingBehavior(); // pipeline behaviour over IAxisMediator
→ LoggingBehavior — automatic request logging
Installation
dotnet add package AxisLogger
AxisLogger depends directly on AxisMediator.Contracts (for the ambient identifiers); AxisResult (used by LogResult) comes transitively through it.
→ Full guide: Getting started
The map (jump to what you need)
| Group | You want to… | Detail |
|---|---|---|
Contract · IAxisLogger<T> ⭐ |
log structured entries with auto-enrichment | iaxislogger.md |
LogResult |
log an AxisResult outcome in one line |
log-result.md |
LoggingBehavior |
log every mediator request automatically | logging-behavior.md |
Categories · IAxisLogger<T> |
how the T flows into structured props |
categories.md |
| Why? | the case against ILogger<T> directly |
why-axislogger.md |
| Reference | every member at a glance | api-reference.md |
Start here: Getting started · The IAxisLogger<T> contract · Why AxisLogger?
Fundamentals: LogResult — structured outcomes · LoggingBehavior — automatic request logging · Categories and structured properties
Reference & extras: API reference
Design principles
- Structured first. Every public overload takes
(Key, Value)pairs — never an interpolated string with values baked in. Search and aggregation rely on it. - Auto-enrichment is non-negotiable.
OriginId,TraceId,JourneyIdalways travel with the entry. If you forget to pass them, the logger does not. LogResultis the railway's logger. A typed outcome deserves a typed log entry, with the right level chosen for you.- The behaviour is opt-in.
LoggingBehaviorwires structured logging into the mediator pipeline with one line; turn it off when you do not need it. - Sinks stay free. AxisLogger does not pick the sink —
ILogger<T>does. Use Serilog, NLog, OpenTelemetry-Logs, anything that plugs intoMicrosoft.Extensions.Logging.
License
Apache 2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- AxisMediator.Contracts (>= 2.2.0)
- AxisResult (>= 2.2.0)
- Microsoft.Extensions.Logging (>= 10.0.10)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Logging.Console (>= 10.0.10)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on AxisLogger:
| Package | Downloads |
|---|---|
|
AxisTelemetry
Part of the Axis Framework — an opinionated, ports-and-adapters .NET framework. |
|
|
AxisMediator
Part of the Axis Framework — an opinionated, ports-and-adapters .NET framework. |
|
|
AxisSaga
Part of the Axis Framework — an opinionated, ports-and-adapters .NET framework. |
|
|
AxisCache.Repository
Part of the Axis Framework — an opinionated, ports-and-adapters .NET framework. |
|
|
AxisRepository.MySql
Part of the Axis Framework — an opinionated, ports-and-adapters .NET framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.