feat:Initial commit
This commit is contained in:
24
StoreService/Extensions/LoggingExtensions.cs
Normal file
24
StoreService/Extensions/LoggingExtensions.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Serilog;
|
||||
|
||||
namespace StoreService.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Logging related extensions (Serilog configuration).
|
||||
/// </summary>
|
||||
public static class LoggingExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds Serilog configuration for the host using appsettings.json (Serilog section).
|
||||
/// </summary>
|
||||
public static IHostBuilder AddSerilogLogging(this IHostBuilder hostBuilder)
|
||||
{
|
||||
hostBuilder.UseSerilog((ctx, services, cfg) =>
|
||||
{
|
||||
cfg.ReadFrom.Configuration(ctx.Configuration)
|
||||
.ReadFrom.Services(services)
|
||||
.Enrich.FromLogContext();
|
||||
});
|
||||
return hostBuilder;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user