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                
#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                

SerilogUI

A UI provider for serilog to allow users to change log levels without changing appsettings.json or restarting the application.

Steps

  1. Install Serilog.Aspnetcore.Configuration.UI Package in .NET 7 Web API
  2. Add below code
    var logLevelSwitch = new LoggingLevelSwitch();
    
    builder.Logging.ClearProviders();
      builder.Host.UseSerilog((hostingContext, loggerConfiguration) =>
      {
        loggerConfiguration.ReadFrom.Configuration(config);
        loggerConfiguration.AddLogLevelManager(logLevelSwitch, config);
      });
  1. Add below code to register all dependencies
    builder.Services.AddSerilogLogLevelConfigurationUI(logLevelSwitch);
  1. 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

  1. Run application
  2. Open new browser tab or new browser window
  3. Open Url http:<API host: Port>/log/ui e.g http://localhost:4000/log/ui
  4. 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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 228 5/20/2023
1.0.0 173 5/20/2023

Created an UI to allow users to change serilog's log level without restarting web api via html page