Serilog.AspNetCore
Serilog.Sinks.Seq
builder.Host.UseSerilog((context, loggerConfig) => loggerConfig.ReadFrom.Configuration(context.Configuration));
"Serilog": { "WriteTo": [ { "Name": "Seq", "Args": {"serverUrl": "http://localhost:5341"} } ] }
` public static class SerilogSeqConfigHelper { public static void Configure(string applicationName) { var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .AddEnvironmentVariables() .Build();
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
#if DEBUG .MinimumLevel.Debug() #else .MinimumLevel.Information() #endif .MinimumLevel.Override("Microsoft", Serilog.Events.LogEventLevel.Information) .MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Warning) .Enrich.FromLogContext() .Enrich.WithProperty("Application", $"{applicationName}") .WriteTo.File("logs/logs.txt") .WriteTo.Console() .WriteTo.Seq("http://localhost:5341") .CreateLogger(); } } `