Serilog.Sinks.RichTextBox.WinForms.Colored
2.0.0
Requires NuGet 3.3 or higher.
dotnet add package Serilog.Sinks.RichTextBox.WinForms.Colored --version 2.0.0
NuGet\Install-Package Serilog.Sinks.RichTextBox.WinForms.Colored -Version 2.0.0
<PackageReference Include="Serilog.Sinks.RichTextBox.WinForms.Colored" Version="2.0.0" />
paket add Serilog.Sinks.RichTextBox.WinForms.Colored --version 2.0.0
#r "nuget: Serilog.Sinks.RichTextBox.WinForms.Colored, 2.0.0"
// Install Serilog.Sinks.RichTextBox.WinForms.Colored as a Cake Addin #addin nuget:?package=Serilog.Sinks.RichTextBox.WinForms.Colored&version=2.0.0 // Install Serilog.Sinks.RichTextBox.WinForms.Colored as a Cake Tool #tool nuget:?package=Serilog.Sinks.RichTextBox.WinForms.Colored&version=2.0.0
Serilog.Sinks.RichTextBox.WinForms.Colored
A Serilog sink that writes log events to a WinForms RichTextBox with support for coloring and custom themes.
Features
- Write log events to a WinForms RichTextBox control
- Customizable themes (Dark and Light presets available)
- Configurable output templates
- Auto-scrolling option
- Line limit control
Installation
Install the package from NuGet:
Install-Package Serilog.Sinks.RichTextBox.WinForms.Colored
Usage
Basic Setup
Declare your RichTextBox control:
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";
}
Configure the logger:
Log.Logger = new LoggerConfiguration()
.WriteTo.RichTextBox(richTextBox1)
.CreateLogger();
Log.Information("Hello, world!");
Advanced Configuration
You can customize the sink using various parameters from the RichTextBox extension method:
Log.Logger = new LoggerConfiguration()
.WriteTo.RichTextBox(
richTextBoxControl: richTextBox1,
minimumLogEventLevel: LogEventLevel.Debug,
outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}",
theme: ThemePresets.Light,
messageBatchSize: 100,
messagePendingInterval: 10,
autoScroll: true,
maxLogLines: 1000)
.CreateLogger();
Themes
Available built-in themes:
Theme | Description |
---|---|
ThemePresets.Dark |
Similar to the default theme of Serilog.Sinks.Console |
ThemePresets.Light |
Light background with contrasting colors |
Support and Contribute
If you find value in this project, there are several ways you can contribute:
- Become a Sponsor: Support the project through GitHub Sponsors.
- Show Your Appreciation: Give the project a star on GitHub.
- Contribute: Improve documentation, report bugs, or submit pull requests.
License
This project is licensed under the Apache License, Version 2.0.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. net8.0-windows7.0 is compatible. |
.NET Framework | net452 is compatible. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 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.
- Added support for .NET 8
- Added support for .NET Framework 4.5.2
- Added outputTemplate and formatProvider to options
See repository for more information:
https://github.com/vonhoff/Serilog.Sinks.RichTextBox.WinForms.Colored