I’m using SEQ for structured logging in my .NET application (Serilog). I want SEQ to display a colored badge (highlight) with the elapsed time (in ms) on the right side of the log message, just like it does for ASP.NET Core health check logs.
Example of what I want:
In health check logs, SEQ automatically shows a badge like 423 ms on the right side of the message:
What I tried: I log messages like this:
_logger.LogInformation(
"Health check GET https://myapp/health succeeded with status code 200 in {Elapsed:0.000} ms",
405.705);
var position = new { Latitude = 25, Longitude = 134 };
var elapsedMs = 34;
_logger.LogInformation("Processed {@Position} in {Elapsed:000} ms.", position, elapsedMs);
How can I make SEQ display the metric badge for my custom logs, just like it does for health checks? I don't get what I need. I tried adding to the signal
This is due to the difference between log events and spans.
Events created using ILogger
are log events, which have a single timestamp value.
The events with colored timing bars are spans, and created using System.Diagnostics.Activity
. Spans have a start time and an end time, so Seq displays the colored bar showing the elapsed time between the start and end.
You can turn your custom event into a span using either System.Diagnostics.Activity
, or SerilogTracing.