Search code examples
c#winformsserilogserilog-sinks-file

View Serilog logs in Windows Forms application


I have a C# Windows Forms application that is referencing a DLL (managed code) that is using SeriLog to log events. The SeriLog logger is defined in the Windows Forms (main) application, so I have control over the type of sink I am using. Currently I am just logging to a local text file.

My question: is there an elegant way for me to view the log in a Listbox or similar WinForms control in real time while the application is running? The only way I can see at the moment is to read the Log file every few seconds and display the latest item. But I am sure there may be a more elegant way to do capture just the last one or two logged items?


Solution

  • This has the exact answer you're looking for: Is it possible to display Serilog log in the program's GUI?

    However something has happened in the last 5 years!!! There's now a library called: https://github.com/serilog/serilog-sinks-reflectinsight

    We've added a Serilog Sink for ReflectInsight live log viewer. This allows you to leverage your current investment in Serilog, but leverage the power and flexibility that comes with the ReflectInsight viewer. You can view your Serilog messages in real-time, in a rich viewer that allows you to filter out and search for what really matters to you.