Serilog.Aspnetcore.Configuration.UI
1.0.1
dotnet add package Serilog.Aspnetcore.Configuration.UI --version 1.0.1
NuGet\Install-Package Serilog.Aspnetcore.Configuration.UI -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Serilog.Aspnetcore.Configuration.UI" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Aspnetcore.Configuration.UI --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Serilog.Aspnetcore.Configuration.UI, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Serilog.Aspnetcore.Configuration.UI as a Cake Addin #addin nuget:?package=Serilog.Aspnetcore.Configuration.UI&version=1.0.1 // Install Serilog.Aspnetcore.Configuration.UI as a Cake Tool #tool nuget:?package=Serilog.Aspnetcore.Configuration.UI&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SerilogUI
A UI provider for serilog to allow users to change log levels without changing appsettings.json or restarting the application.
Steps
- Install Serilog.Aspnetcore.Configuration.UI Package in .NET 7 Web API
- Add below code
var logLevelSwitch = new LoggingLevelSwitch();
builder.Logging.ClearProviders();
builder.Host.UseSerilog((hostingContext, loggerConfiguration) =>
{
loggerConfiguration.ReadFrom.Configuration(config);
loggerConfiguration.AddLogLevelManager(logLevelSwitch, config);
});
- Add below code to register all dependencies
builder.Services.AddSerilogLogLevelConfigurationUI(logLevelSwitch);
- Add Below code to configure Middleware in pipeline.
app.UseSerilogConfigurationUI();
Samples
Sample folder contains a sample implementation with a test Web API
How to change Log levels
- Run application
- Open new browser tab or new browser window
- Open Url http:<API host: Port>/log/ui e.g http://localhost:4000/log/ui
- on configuration page choose log level that you want to set and then click on "Set Log Level" button and it will change "Current Log Level"
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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Configuration.Binder (>= 7.0.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- Serilog (>= 2.12.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Created an UI to allow users to change serilog's log level without restarting web api via html page