Skip to content

Latest commit

 

History

History
47 lines (31 loc) · 1.86 KB

README.md

File metadata and controls

47 lines (31 loc) · 1.86 KB

Serilog.Sinks.WPF

NuGet version Build and Publish Nuget

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