Reputation: 7457
I'm using Serilog
with Elasticsearch sink with the configurations like this:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft", LogEventLevel.Verbose)
.Enrich.FromLogContext()
.Enrich.WithExceptionDetails()
.Enrich.WithProperty("Application", "abc")
.Enrich.WithProperty("Environment", env.EnvironmentName)
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(Configuration["LoggingEndpoint"]))
{
AutoRegisterTemplate = true,
CustomFormatter = new ExceptionAsObjectJsonFormatter(renderMessage: true) // Better formatting for exceptions
})
// and later:
services.AddLogging(loggingBuilder =>
loggingBuilder.AddSerilog());
But I can see every log twice, with a couple of milliseconds difference in their timestamp, on the Kibana. I tried the solutions provided here, just in case they might help, but no luck.
Upvotes: 12
Views: 5935
Reputation: 2766
This is probably the case because you are configuring Serilog inside your appsettings.json and also inside code. This wil Log everything twice.
Upvotes: 16