Provides common logging setup using Serilog.
Find a file
2025-10-03 10:42:09 +01:00
.forgejo/workflows Initial commit 2025-10-03 08:08:37 +01:00
Alveus.Common.Logging Add setting up logging using IConfiguration 2025-10-03 09:02:20 +01:00
.gitignore Initial commit 2025-10-03 08:08:37 +01:00
Alveus.Common.Logging.sln Initial commit 2025-10-03 08:08:37 +01:00
Alveus.ruleset Initial commit 2025-10-03 08:08:37 +01:00
LICENSE.md Initial commit 2025-10-03 08:08:37 +01:00
README.md Update README.md 2025-10-03 10:42:09 +01:00

Alveus.Common.Logging

Release Build status

A .NET library that wraps around Serilog to provide a simple interface to set up logging by either providing the configuration class instance, or by passing in IConfiguration to bind against the app settings.

Overview

This library simplifies the setup of structured logging in .NET applications using Serilog. It provides:

  • Easy integration with dependency injection
  • Environment and exception enrichment
  • Console and Seq sink support
  • Flexible configuration options

Installation

Install the package via NuGet feed https://nuget.alveus.dev

Usage Example

Here's a basic example of how to set up logging in your application:

var serviceCollection = new ServiceCollection();

// Define your logging configuration
var loggingConfig = new LoggingConfig
{
    MinimumLogLevel = LogLevel.Information
};

// Set up logging with the configuration
serviceCollection.SetupLogging(loggingConfig, loggerConfiguration =>
{
    // Additional customization of Serilog goes here
    loggerConfiguration.Enrich.WithProperty("Application", "MyApp");
});

// Build the service provider
var serviceProvider = serviceCollection.BuildServiceProvider();

// Resolve the logger and use it
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();

logger.LogInformation("Custom configuration applied successfully");