Skip to content

Fast.Logging

Public members, parameters, returns, and exceptions

Targets: net8.0;net9.0;net10.0.

Contract and constraints

Console formatting and per-level file logging. AddLoggingService(services, configuration, section = "Logging:Fast") binds LoggingSettingsOptions, registers providers and adds a startup filter. File names follow logs/<level><FileFormat>.log. The host owns directory permissions, storage capacity and retention. Installing the package does not prove that file output works. Providers manage console writers and redirected output. Redact sensitive values before passing them to logging APIs; formatters do not guarantee removal of credentials. The examples register logging and use it through application services; they have not been executed as part of this documentation update.

Installation and examples

Install the package

bash
dotnet add package Fast.Logging

Example 1

csharp
using Fast.Logging;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLoggingService(builder.Configuration);

var app = builder.Build();
app.Logger.LogInformation("Application configured");
app.MapGet("/health", () => "healthy");
app.Run();

public sealed class Worker(ILogger<Worker> logger)
{
    public void Report(int count) => logger.LogInformation("Processed {Count} items", count);
}

Web-host examples belong in a consumer project using Microsoft.NET.Sdk.Web and a supported .NET target. IaaS examples can be used in an ordinary class library. Registration precedes builder.Build(); configure middleware and endpoints before app.Run(). Samples retain their original code and comments. No host, external service, database operation or client generator was run, and these snippets have not been compiled in this update.

Source reference