Skip to content

Latest commit

 

History

History
61 lines (38 loc) · 4.84 KB

Sagara.Core.Logging.Serilog.SerilogExtensions.md

File metadata and controls

61 lines (38 loc) · 4.84 KB

SerilogExtensions Class

public static class SerilogExtensions

Inheritance System.Object 🡒 SerilogExtensions

Methods

SerilogExtensions.UseSerilog(this IHostApplicationBuilder, Action<IHostApplicationBuilder,IServiceProvider,LoggerConfiguration>, bool, bool) Method

Sets Serilog as the logging provider.

public static Microsoft.Extensions.Hosting.IHostApplicationBuilder UseSerilog(this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, System.Action<Microsoft.Extensions.Hosting.IHostApplicationBuilder,System.IServiceProvider,Serilog.LoggerConfiguration> configureLogger, bool preserveStaticLogger=false, bool writeToProviders=false);

Parameters

builder Microsoft.Extensions.Hosting.IHostApplicationBuilder

The Microsoft.Extensions.Hosting.IHostApplicationBuilder to configure.

configureLogger System.Action<Microsoft.Extensions.Hosting.IHostApplicationBuilder,System.IServiceProvider,Serilog.LoggerConfiguration>

The delegate for configuring the Serilog.LoggerConfiguration that will be used
to construct a Serilog.Core.Logger.

preserveStaticLogger System.Boolean

Indicates whether to preserve the value of Serilog.Log.Logger.

writeToProviders System.Boolean

By default, Serilog does not write events to Microsoft.Extensions.Logging.ILoggerProviders
registered through the Microsoft.Extensions.Logging API. Normally, equivalent Serilog sinks are used in place of providers.
Specify true to write events to all providers.

Returns

Microsoft.Extensions.Hosting.IHostApplicationBuilder
The host application builder.

Remarks

This is (hopefully) a temporary replacement for Serilog.Extensions.Hosting.UseSerilog. It's necessary
to support working with the new Host.CreateApplicationBuilder() pattern being rolled out in .NET 7, which
does not currently support the IHostBuilder interface.

See: dotnet/runtime#81090 (comment)