Serilog.Sinks.RichTextBox.WinForms.Colored
1.0.0
See the version list below for details.
dotnet add package Serilog.Sinks.RichTextBox.WinForms.Colored --version 1.0.0
NuGet\Install-Package Serilog.Sinks.RichTextBox.WinForms.Colored -Version 1.0.0
<PackageReference Include="Serilog.Sinks.RichTextBox.WinForms.Colored" Version="1.0.0" />
paket add Serilog.Sinks.RichTextBox.WinForms.Colored --version 1.0.0
#r "nuget: Serilog.Sinks.RichTextBox.WinForms.Colored, 1.0.0"
// Install Serilog.Sinks.RichTextBox.WinForms.Colored as a Cake Addin #addin nuget:?package=Serilog.Sinks.RichTextBox.WinForms.Colored&version=1.0.0 // Install Serilog.Sinks.RichTextBox.WinForms.Colored as a Cake Tool #tool nuget:?package=Serilog.Sinks.RichTextBox.WinForms.Colored&version=1.0.0
<div align="center"> <img src="Assets/serilog-sink-nuget.png" alt="Serilog.Sinks.RichTextBox.WinForms" width="100" /> </div>
<h1 align="center">Serilog.Sinks.RichTextBox.WinForms.Colored</h1> <div align="center">
A Serilog sink that writes log events to any WinForms RichTextBox control with coloring and custom theme support.
This sink is based on the WPF RichTextBox Sink by C. Augusto Proiete. </div>
Give a Star! ⭐
If you like or are using this project please give it a star. Thanks!
Getting started 🚀
Declare your RichTextBox control and give it a name that you can reference it from the code-behind. e.g.:
private System.Windows.Forms.RichTextBox richTextBox1;
private void InitializeComponent()
{
this.richTextBox1.BackColor = System.Drawing.SystemColors.Window;
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBox1.Font = new System.Drawing.Font("Consolas", 10.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.richTextBox1.Location = new System.Drawing.Point(0, 0);
this.richTextBox1.Name = "richTextBox1";
}
Then enable the sink using WriteTo.RichTextBox()
:
Log.Logger = new LoggerConfiguration()
.WriteTo.RichTextBox(richTextBox1)
.CreateLogger();
Log.Information("Hello, world!");
Log events will be written to the RichTextBox
control:
[11:54:36 INF] Hello, world!
Themes
Themes can be specified when configuring the sink:
.WriteTo.RichTextBox(MyRichTextBox, theme: RichTextBoxConsoleTheme.Dark)
The following built-in themes are available at this time:
Theme | Description |
---|---|
RichTextBoxConsoleTheme.Dark |
Styled to replicate the default theme of Serilog.Sinks.Console; This is the default when no theme is specified |
RichTextBoxConsoleTheme.Light |
A theme with a light background and contrasting colors. |
Output templates
The format of events to the RichTextBox can be modified using the outputTemplate
configuration parameter:
.WriteTo.RichTextBox(MyRichTextBox,
outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")
The default template, shown in the example above, uses built-in properties like Timestamp
and Level
. Properties from events, including those attached using enrichers, can also appear in the output template.
Copyright © 2022 Simon Vonhoff & Contributors - Provided under the Apache License, Version 2.0.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0-windows7.0 is compatible. net6.0-windows was computed. net7.0-windows was computed. net8.0-windows was computed. |
-
net5.0-windows7.0
- Serilog (>= 2.11.0)
- Serilog.Enrichers.Thread (>= 3.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.