Logging¶
Nalix.Logging provides the built-in logger implementation used across the Nalix stack.
Source mapping¶
src/Nalix.Logging/NLogix.cssrc/Nalix.Logging/NLogix.Host.cssrc/Nalix.Logging/Extensions/NLogixFx.cssrc/Nalix.Logging/Extensions/NLogixFx.Internal.cssrc/Nalix.Logging/Extensions/NLogixFx.Level.cssrc/Nalix.Logging/Options/NLogixOptions.cssrc/Nalix.Logging/Options/FileLogOptions.cssrc/Nalix.Logging/Options/ConsoleLogOptions.cssrc/Nalix.Logging/NLogixDistributor.cs
Main types¶
NLogixNLogix.HostNLogixOptionsNLogixFxNLogixDistributorINLogixTargetINLogixDistributorINLogixFormatterINLogixErrorHandler
What it does¶
- implements
ILogger - supports multiple targets
- allows programmatic configuration
- works well as the shared logger registered through
InstanceManager
Basic usage¶
using Nalix.Logging;
NLogix logger = NLogix.Host.Instance;
logger.Info("server-started");
logger.Warn("slow-handler");
logger.Error("dispatch-failed");
Custom setup¶
using Microsoft.Extensions.Logging;
using Nalix.Logging;
using Nalix.Logging.Sinks;
NLogix logger = new(cfg =>
{
cfg.SetMinimumLevel(LogLevel.Debug)
.RegisterTarget(new BatchConsoleLogTarget())
.RegisterTarget(new BatchFileLogTarget());
});
Typical integration¶
using Microsoft.Extensions.Logging;
using Nalix.Framework.Injection;
using Nalix.Logging;
InstanceManager.Instance.Register<ILogger>(NLogix.Host.Instance);
This is the usual pattern for server startup so listeners, dispatch, and framework services use the same logger instance.
NLogixDistributor¶
NLogixDistributor is the internal fan-out component that forwards published entries to registered targets.
Source mapping¶
src/Nalix.Logging/NLogixDistributor.cs
It is responsible for:
- registering
INLogixTargetimplementations - publishing each entry to every registered target
- coordinating target lifetime and disposal
NLogix owns one distributor instance and uses it as the publish path after level filtering.
Notes¶
- keep one shared logger for the process when possible
- prefer registering targets during startup, not mid-flight
NLogixapplies both console and file targets by default when you construct it without a custom configuration delegateNLogix.Host.Instancecurrently boots a shared logger with a console target only andDebugminimum level