-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Expand file tree
/
Copy pathLoggerConfigs.cs
More file actions
21 lines (18 loc) · 744 Bytes
/
Copy pathLoggerConfigs.cs
File metadata and controls
21 lines (18 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using System.Globalization;
using Serilog;
namespace Clean.Architecture.Web.Configurations;
public static class LoggerConfigs
{
public static WebApplicationBuilder AddLoggerConfigs(this WebApplicationBuilder builder)
{
// Add Serilog as an additional logging provider alongside OpenTelemetry
// This allows both Serilog (for console/file) and OpenTelemetry (for Aspire) to work together
builder.Logging.AddSerilog(new LoggerConfiguration()
.ReadFrom.Configuration(builder.Configuration)
.Enrich.FromLogContext()
.Enrich.WithProperty("Application", builder.Environment.ApplicationName)
.WriteTo.Console(formatProvider: CultureInfo.InvariantCulture)
.CreateLogger());
return builder;
}
}