Search code examples
c#elasticsearchserilog

Serilog logging to elasticsearch, long delay, is a configuration available for logging faster


I'm in the process of converting a small project from log4net to serilog using the elasticsearch sink and rolling file sink. I have noticed that when logging to the elasticsearch sink it takes a long time before it appears in elasticsearch. By long time I mean that many lines of code are executed before the log statement appears in elasticsearch. This is however not the case for the log file.

I have stepped through my code, so it isn't a delay with logging within the elastisearch "db", but rather a delay in the sink to deliver it. Considering this I'm a little afraid of loosing valuable log statements towards the elasticsearch, when the application fails, due to the delay. I do have the file as a backup, but it would be nice to be able to trust that the elasticsearch sink doesn't loose logs.

I have looked for information of what delay could be expected, but couldn't find any information. Furthermore, I also looked for a configuration for the sink to log faster, but no luck.

What I'm looking for is a configuration setting that can reduce the delay in the elasticsearch sink ?


Solution

  • Just use: Install-Package Serilog.Sinks.ElasticSearch and set batchPostingLimit to 5

    See in : https://github.com/serilog/serilog-sinks-elasticsearch