Serilog.Sinks.WinForms.Core
1.0.3
dotnet add package Serilog.Sinks.WinForms.Core --version 1.0.3
NuGet\Install-Package Serilog.Sinks.WinForms.Core -Version 1.0.3
<PackageReference Include="Serilog.Sinks.WinForms.Core" Version="1.0.3" />
paket add Serilog.Sinks.WinForms.Core --version 1.0.3
#r "nuget: Serilog.Sinks.WinForms.Core, 1.0.3"
// Install Serilog.Sinks.WinForms.Core as a Cake Addin #addin nuget:?package=Serilog.Sinks.WinForms.Core&version=1.0.3 // Install Serilog.Sinks.WinForms.Core as a Cake Tool #tool nuget:?package=Serilog.Sinks.WinForms.Core&version=1.0.3
Writes Serilog events to Windows Froms Application TextBox or Datagridview control from anywhere in your application.
Getting started
Install the Serilog.Sinks.WinForms.Core package from NuGet:
Install-Package Serilog.Sinks.WinForms.Core
To configure the sink in C# code, call WriteToSimpleAndRichTextBox()
or WriteToJsonTextBox()
or WriteToGridView()
during logger configuration:
Simple Text Formatted Log And Rich TextBox Log Control
SimpleLogTextBox or RichTextBoxLogControl 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 Configuration. SimpleLogTextBox 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();
JsonLogTextBox with custom Configuration. JsonLogTextBox accepts ITextFormatter
Log.Logger = new LoggerConfiguration()
.WriteToJsonTextBox(new JsonFormatter())
.CreateLogger();
Datagridview Log
GridLog can be used from visual studio toolbox once the package is added to the project.
Log.Logger = new LoggerConfiguration()
.WriteToGridView()
.CreateLogger();
Log For Context
SimpleLogTextBox, RichTextBoxLogControl or JsonLogTextBox can be configured to display log for specific Context. All of the controls have property For Context which can be configured with namespace.classname
Note: Remember to configure Logger instance with Enrich.FromLogContext()
Save and Clear Logs
SimpleLogTextBox, RichTextBoxLogControl or JsonLogTextBox have two method available for saving log to file or clear the log from the log control. ClearLogs() AND SaveLogToFile()
Sample Code
Find the sample running application here
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0-windows7.0 is compatible. net6.0-windows was computed. net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.