![]() |
VOOZH | about |
dotnet add package Serilog.Extensions --version 10.0.0
NuGet\Install-Package Serilog.Extensions -Version 10.0.0
<PackageReference Include="Serilog.Extensions" Version="10.0.0" />
<PackageVersion Include="Serilog.Extensions" Version="10.0.0" />Directory.Packages.props
<PackageReference Include="Serilog.Extensions" />Project file
paket add Serilog.Extensions --version 10.0.0
#r "nuget: Serilog.Extensions, 10.0.0"
#:package Serilog.Extensions@10.0.0
#addin nuget:?package=Serilog.Extensions&version=10.0.0Install as a Cake Addin
#tool nuget:?package=Serilog.Extensions&version=10.0.0Install as a Cake Tool
๐ NuGet Version
๐ License: MIT
A lightweight library to simplify Serilog integration in .NET applications. It provides fluent extension methods for WebApplicationBuilder, IHostBuilder, and IServiceCollection, along with powerful conditional logging capabilities.
appsettings.serilog.json).Assert, When, WhenNot).dotnet add package Serilog.Extensions
using Serilog.Extensions;
var builder = WebApplication.CreateBuilder(args);
// Setup Serilog using appsettings.json
builder.UseSerilog();
var app = builder.Build();
app.UseSerilogRequestLogging(); // Optional: Add request logging middleware
app.Run();
using Serilog.Extensions;
Host.CreateDefaultBuilder(args)
.UseSerilog() // Uses host configuration
.Build()
.Run();
If you prefer to keep your logging configuration separate from your main appsettings.json, use UseSerilogJson().
Add the location of your logging config:
{
"JsonFileSettingsOptions": [
{
"Filename": "serilog.config.json",
"Optional": false,
"ReloadOnChange": true
}
]
}
builder.UseSerilogJson();
| Property | Type | Description |
|---|---|---|
Filename |
string | Path to the Serilog JSON configuration file. |
Optional |
bool | If false, throws an exception if the file is missing. |
ReloadOnChange |
bool | If true, updates logger settings without restarting the app. |
Stop wrapping log calls in if statements. Use the built-in conditional extensions for cleaner code.
Assert PatternLogs a message only if the condition is false (ideal for validation).
// Logs Error only if user is null
logger.AssertError(user != null, "User not found in database");
// Logs Warning if count is not greater than 0
logger.AssertWarning(items.Count > 0, "Processing an empty list");
When PatternExplicitly log based on truthiness.
// Logs only when true
logger.InfoWhen(isNewUser, "Sending welcome email to {Email}", email);
// Logs only when false
logger.DebugWhenNot(isCacheHit, "Fetching data from remote API...");
Methods available for all levels: Trace, Debug, Info, Warn, Error, Critical.
If you are not using Dependency Injection, you can use the LoggerFactory directly:
using Serilog.Extensions.Services;
// Create a logger with default settings
var logger = LoggerFactory.New();
// Create a logger from a specific config file
var logger = LoggerFactory.New("path/to/config.json");
This project is licensed under the MIT License - see the file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 4 NuGet packages that depend on Serilog.Extensions:
| Package | Downloads |
|---|---|
|
GN2.Business.Base
Provides a api library for business services. |
|
|
Kmd.CqrsCore
Package Description |
|
|
Zokhrof.Appbase.Messenger
Package Description |
|
|
ItTitansGmbh.Utility.SeriLogSQLTranslator
SeriLogSQL Translator is a powerful and user-friendly tool designed to bridge the gap between SeriLog and SQL. Leveraging a robust parsing system, it transforms SeriLog log strings into executable SQL commands, eliminating the need for manual translation and making your database interactions more efficient and reliable. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.0 | 25,061 | 2/4/2026 |
| 9.1.0 | 33,807 | 11/8/2025 |
| 9.0.0 | 397 | 11/8/2025 |
| 8.1.0 | 157,563 | 6/16/2025 |
| 8.0.3 | 239,229 | 11/18/2024 |
| 8.0.2 | 52,754 | 9/13/2024 |
| 8.0.1 | 76,075 | 7/10/2024 |
| 8.0.0 | 56,081 | 1/18/2024 |
| 7.1.0 | 14,797 | 5/3/2024 |
| 7.0.0 | 4,611 | 1/28/2024 |
| 3.4.3 | 966 | 1/18/2024 |
| 3.4.2 | 20,407 | 8/17/2023 |
| 3.4.0 | 8,706 | 5/20/2023 |
| 3.3.1 | 2,693 | 3/14/2023 |
| 3.3.0 | 7,584 | 2/21/2023 |
| 3.2.2 | 1,219 | 2/21/2023 |
| 3.2.1 | 1,030 | 2/21/2023 |
| 3.2.0 | 1,170 | 2/5/2023 |
| 3.1.0 | 3,111 | 12/8/2022 |
| 3.0.0 | 1,490 | 11/25/2022 |