21

I'm aware of some free/commercial visualizer of structured logging, like seq, retrace. The problem is I don't want to directly add as sinks, because I don't want every single logging action to involve sending out an Http request to the log server. Instead, I'd like to log to local files as quickly as possible, while still have the ability to review and search the logged file content in a structured way.

So is there a practical solution to this? Thanks.

3
  • 2
    Just a quick clarification, in case it simplifies things for you: the Serilog sinks (like the Seq sink, and probably most other network-based sinks) don't block the application while sending logs over HTTP: logs are written to an in-memory buffer - very quickly - and then a background thread ships these off in batches via HTTP. Usually not a lot of noticeable impact on the app. Sep 24, 2018 at 5:26
  • @NicholasBlumhardt thanks for the clarification which helps a lot. Would you mind explaining further more what would happen if the actual network flushing fails, possibly due to a network disconnection for example? Would there be some sort of retry mechanism, or I'd have chance to lose some log items when viewing from the online dashboard?
    – Nico
    Sep 24, 2018 at 7:22
  • 1
    NW! Most of the sinks will retry with exponential back-off in a 10 minute window; after that, log events will be dropped so that the application's memory use doesn't balloon out. Sep 24, 2018 at 22:26

5 Answers 5

8

I tried many apps but the TailBlazer seems to be the best for me, it's free and really easy to use. Here

1
  • 2
    Looks like a great alternative for logs generated by ie. Log4Net, but not for structured logging as I would expect the tool to be able to visualize the structured data better. Jun 3, 2021 at 13:08
6

One option is to write the files using the file sink and Serilog.Formatting.Compact:

.WriteTo.File(new CompactJsonFormatter(), "log.clef")

You can then use something like jq or clef-tool to read/query the logs, including structured data:

clef -i log.clef --filter="SomeProp > 100"

where SomeProp > 100 is a Serilog filter expression.

5

Compact Log Viewer is available in Windows Store to download free. Releases can also be downloaded from the GitHub Repo here:

https://github.com/warrenbuckley/Compact-Log-Format-Viewer/releases

Make sure you add in the Nuget package Serilog.Formatting.Compact.

Inside Program.cs if you have a .net6 + application (for example a Blazor Server side app), you can add this to set up SeriLog :

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Debug()
    .MinimumLevel.Override("Microsoft", Serilog.Events.LogEventLevel.Information)
    .Enrich.FromLogContext()
    .WriteTo.File(new CompactJsonFormatter(), "Logs/log_sweets.json", rollingInterval: RollingInterval.Day)
    .CreateLogger();

builder.Logging.ClearProviders();
builder.Logging.AddSerilog();

Compact Log Viewer only works with .json files when I test it here, so that is why I use the CompactLogJsonFormatter above

SeriLog - Complact Log Viewer

4

I've used this tool for Serilog: https://github.com/warrenbuckley/Compact-Log-Format-Viewer

It does work nice, I miss some features but this tool can also visualize the structured data of ie. serilog-files.

1

I have been using Analogy Log Viewer from Lior Banai for the last year or so and it works great for Serilog (especially the Json Visualizer view).

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.