For some reason, I find it very hard to understand what's going on with Serilog configuration. I have a web api with .NET Core 2.1 and installed serilog.sink.logstash. My startup has:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { var serverURL = Configuration.GetSection("Logging")["logstashServer"]; var logger = new LoggerConfiguration() .Enrich.FromLogContext() .Enrich.WithProperty("Enviroment", env.EnvironmentName) .Enrich.WithProperty("ApplicationName", "MyApp") .WriteTo.LogstashHttp(serverURL); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); logger.WriteTo.Console(); } loggerFactory.AddSerilog(); Log.Logger = logger.CreateLogger(); app.UseCors("CorsPolicy"); app.UseMvc(); } My appsettings has a section:
"Logging": { "logstashServer": "http://192.168.0.6:8101", "IncludeScopes": false, "Serilog": { "MinimumLevel": { "Default": "Error", "Override": { "Microsoft": "Error", "Microsoft.AspNetCore.Hosting": "Error", "Microsoft.AspNetCore.Mvc": "Error", "System": "Error" } } } } No matter what I do, I see both in console and logstash than a lot of unwanted information is logged like:
[14:27:54 INF] Executed action method MyApp.Controllers.LoggerController.Post (MyApp), returned result Microsoft.AspNetCore.Mvc.OkResult in 0.0771ms.
MyApp> [14:27:54 INF] Executing HttpStatusCodeResult, setting HTTP status code 200
MyApp> [14:27:54 INF] Executed action MyApp.Controllers.LoggerController.Post (MyApp) in 2.0855ms
and so on. Why do I see those since I have minimum level error?