Formating ElapsedTime (Timespan) when logging in ElasticSearch with Serilog (C#)

102 views Asked by At

I'm trying to log the elapsed time of a StopWatch with Serilog with an ElasticSearch sink.

I managed to print my log properly in console and file with the following command:

Log.Information("Component {ComponentName} ran tests successfully in {ElapsedTime:mm\\:ss\\.fff}", component.Name, sw.Elapsed);

The log is indeed working properly for file and console: Component "Packages" built successfully in 01:13.139

My issue is that the ElapsedTime field is stored as text inside my ElasticSearch index. How can i force it to a date?

For more context, i'm trying to visualize the average and sum of these elapsed times in a Kibana dashboard

0

There are 0 answers