Serilog.Sinks.WPF

Writes Serilog events to WPF TextBox control from anywhere in your application.

Stars
8

Serilog.Sinks.WPF

Writes Serilog events to WPF TextBox control from anywhere in your application.

Getting started

Install the Serilog.Sinks.WPF package from NuGet:

Install-Package Serilog.Sinks.WPF

To configure the sink in C# code, call WriteToSimpleAndRichTextBox() or WriteToJsonTextBox() during logger configuration:

Simple Text Formatted Log

SimpleLogTextBox can be used from visual studio toolbox once the package is added to the project.

Log.Logger = new LoggerConfiguration()
                        .WriteToSimpleAndRichTextBox()
                        .CreateLogger();

SimpleLogTextBox or RichTextBoxLogControl with custom MessageTemplate. WriteToSimpleAndRichTextBox accepts ITextFormatter

Log.Logger = new LoggerConfiguration()
                        .WriteToSimpleAndRichTextBox(new MessageTemplateTextFormatter("{Timestamp} [{Level}] {Message} {Exception}"))
                        .CreateLogger();
Json Formatted Log

JsonLogTextBox can be used from visual studio toolbox once the package is added to the project.

Log.Logger = new LoggerConfiguration()
                        .WriteToJsonTextBox()
                        .CreateLogger();

Sample Code

Find the sample running application here

Badges
Extracted from project README
NuGet version Nuget
Related Projects