Serilog.Extensions
9.1.0
dotnet add package Serilog.Extensions --version 9.1.0
NuGet\Install-Package Serilog.Extensions -Version 9.1.0
<PackageReference Include="Serilog.Extensions" Version="9.1.0" />
<PackageVersion Include="Serilog.Extensions" Version="9.1.0" />
<PackageReference Include="Serilog.Extensions" />
paket add Serilog.Extensions --version 9.1.0
#r "nuget: Serilog.Extensions, 9.1.0"
#:package Serilog.Extensions@9.1.0
#addin nuget:?package=Serilog.Extensions&version=9.1.0
#tool nuget:?package=Serilog.Extensions&version=9.1.0
Serilog Extensions for WebApplicationBuilder
This NuGet package provides extension methods to easily configure Serilog in your .NET applications. It supports WebApplicationBuilder, IHostBuilder, and IServiceCollection.
Installation
Install the package from NuGet:
dotnet add package Serilog.Extensions
Usage
This package provides two main extension methods for WebApplicationBuilder:
UseSeriLogger()UseSerilogWithJsonFileBuilder()
UseSeriLogger()
This method configures Serilog using the default appsettings.json file.
using YourNamespace;
var builder = WebApplication.CreateBuilder(args);
builder.UseSeriLogger();
UseSerilogWithJsonFileBuilder()
This method allows you to specify a separate JSON file for Serilog configuration.
using YourNamespace;
var builder = WebApplication.CreateBuilder(args);
builder.UseSerilogWithJsonFileBuilder();
To use this method, you need to add a JsonFileSettingsOptions section to your appsettings.json:
{
"JsonFileSettingsOptions": [
{
"Filename": "appsettings-serilog.json",
"Optional": false,
"ReloadOnChange": true
}
]
}
Then, create an appsettings-serilog.json file with your Serilog configuration:
{
"Serilog": {
"Using": [ "Serilog.Sinks.Console" ],
"MinimumLevel": "Information",
"WriteTo": [
{ "Name": "Console" }
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
}
}
Configuration Options
The JsonFileSettingsOptions allows you to specify:
Filename: The name of the Serilog configuration file.Optional: Whether the file is optional (iffalse, an exception will be thrown if the file is not found).ReloadOnChange: Whether to reload the configuration if the file changes.
License
Richard MAH
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net7.0
- Json.AspNetCore (>= 9.0.0)
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 7.0.20)
- Microsoft.Extensions.Configuration (>= 7.0.0)
- Microsoft.Extensions.Configuration.Json (>= 7.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Serilog.AspNetCore (>= 7.0.0)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Enrichers.Process (>= 3.0.0)
- Serilog.Enrichers.Thread (>= 4.0.0)
- Serilog.Expressions (>= 5.0.0)
- Serilog.Extensions.Logging (>= 7.0.0)
-
net8.0
- Json.AspNetCore (>= 9.0.0)
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 8.0.21)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Json (>= 8.0.1)
- Newtonsoft.Json (>= 13.0.4)
- Serilog.AspNetCore (>= 8.0.3)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Enrichers.Process (>= 3.0.0)
- Serilog.Enrichers.Thread (>= 4.0.0)
- Serilog.Expressions (>= 5.0.0)
- Serilog.Extensions.Logging (>= 8.0.0)
-
net9.0
- Json.AspNetCore (>= 9.0.0)
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 9.0.10)
- Microsoft.Extensions.Configuration (>= 9.0.10)
- Microsoft.Extensions.Configuration.Json (>= 9.0.10)
- Newtonsoft.Json (>= 13.0.4)
- Serilog.AspNetCore (>= 9.0.0)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Enrichers.Process (>= 3.0.0)
- Serilog.Enrichers.Thread (>= 4.0.0)
- Serilog.Expressions (>= 5.0.0)
- Serilog.Extensions.Logging (>= 9.0.2)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on Serilog.Extensions:
| Package | Downloads |
|---|---|
|
GN2.Business
Provides a api library for business services. |
|
|
GN2.Business.Base
Provides a api library for business services. |
|
|
GN2.Common.Library
Provides a api library for common library services. |
|
|
GN2.Common.Web
Provides a api library for Common Web services. |
|
|
Kmd.CqrsCore
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.1.0 | 896 | 11/8/2025 |
| 9.0.0 | 140 | 11/8/2025 |
| 8.1.0 | 70,779 | 6/16/2025 |
| 8.0.3 | 163,875 | 11/18/2024 |
| 8.0.2 | 36,097 | 9/13/2024 |
| 8.0.1 | 64,840 | 7/10/2024 |
| 8.0.0 | 46,962 | 1/18/2024 |
| 7.1.0 | 8,646 | 5/3/2024 |
| 7.0.0 | 2,642 | 1/28/2024 |
| 3.4.3 | 585 | 1/18/2024 |
| 3.4.2 | 15,637 | 8/17/2023 |
| 3.4.0 | 8,083 | 5/20/2023 |
| 3.3.1 | 2,331 | 3/14/2023 |
| 3.3.0 | 6,743 | 2/21/2023 |
| 3.2.2 | 764 | 2/21/2023 |
| 3.2.1 | 654 | 2/21/2023 |
| 3.2.0 | 816 | 2/5/2023 |
| 3.1.0 | 2,740 | 12/8/2022 |
| 3.0.0 | 1,116 | 11/25/2022 |
| 2.2.2 | 29,159 | 10/4/2022 |
| 2.2.1 | 825 | 10/3/2022 |
| 2.2.0 | 1,169 | 9/30/2022 |
| 2.1.0 | 2,908 | 9/14/2022 |
| 2.0.1 | 16,978 | 6/1/2022 |
| 2.0.0 | 8,571 | 5/25/2022 |
| 1.1.5 | 29,846 | 4/5/2022 |
| 1.1.4 | 1,288 | 3/14/2022 |
| 1.1.3 | 880 | 3/14/2022 |
| 1.1.2 | 873 | 3/14/2022 |
| 1.1.1 | 867 | 3/14/2022 |
| 1.1.0 | 1,333 | 3/14/2022 |