Serilog.Sinks.RichTextBox.WinForms.Colored 1.2.2

There is a newer version of this package available.
See the version list below for details.

Requires NuGet 3.3 or higher.

dotnet add package Serilog.Sinks.RichTextBox.WinForms.Colored --version 1.2.2
                    
NuGet\Install-Package Serilog.Sinks.RichTextBox.WinForms.Colored -Version 1.2.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Serilog.Sinks.RichTextBox.WinForms.Colored" Version="1.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Serilog.Sinks.RichTextBox.WinForms.Colored" Version="1.2.2" />
                    
Directory.Packages.props
<PackageReference Include="Serilog.Sinks.RichTextBox.WinForms.Colored" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Serilog.Sinks.RichTextBox.WinForms.Colored --version 1.2.2
                    
#r "nuget: Serilog.Sinks.RichTextBox.WinForms.Colored, 1.2.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Serilog.Sinks.RichTextBox.WinForms.Colored@1.2.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Serilog.Sinks.RichTextBox.WinForms.Colored&version=1.2.2
                    
Install as a Cake Addin
#tool nuget:?package=Serilog.Sinks.RichTextBox.WinForms.Colored&version=1.2.2
                    
Install as a Cake Tool

Serilog.Sinks.RichTextBox.WinForms.Colored

NuGet Downloads Latest version License

A Serilog sink that writes log events to any WinForms RichTextBox control with coloring and custom theme support.

Screenshot of Serilog.Sinks.RichTextBox.WinForms.Colored in action

Getting started

Install the Serilog.Sinks.RichTextBox.WinForms.Colored package from NuGet:

Install-Package Serilog.Sinks.RichTextBox.WinForms.Colored

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 the following snippet:

var options = new RichTextBoxSinkOptions(ThemePresets.Dark, 200, 5, true);
var sink = new RichTextBoxSink(richTextBox1, _options);
Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Verbose()
    .WriteTo.Sink(sink, LogEventLevel.Verbose)
    .Enrich.WithThreadId()
    .CreateLogger();

Log.Information("Hello, world!");

Log events will be written to the RichTextBox control:

[11:54:36 INF] Hello, world!

Themes

The following built-in themes are available at this time:

Theme Description
ThemePresets.Dark Styled to replicate the default theme of Serilog.Sinks.Console
ThemePresets.Light A theme with a light background and contrasting colors.

Output templates

The format of events to the RichTextBox can be modified by providing a template renderer to the sink.

var options = new RichTextBoxSinkOptions(ThemePresets.Dark, 200, 5, true);
var renderer = new TemplateRenderer(ThemePresets.Dark, "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}");
var sink = new RichTextBoxSink(richTextBox1, _options, renderer);
Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Verbose()
    .WriteTo.Sink(sink, LogEventLevel.Verbose)
    .Enrich.WithThreadId()
    .CreateLogger();

Log.Information("Hello, world!");

Acknowledgments

If you find this sink useful in your projects, consider leaving a star! ⭐

Contribution

If you want to contribute to this project, you are welcome to submit pull requests or report issues on GitHub.

License

This project is licensed under the terms of the Apache License, Version 2.0.

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0-windows7.0

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Serilog.Sinks.RichTextBox.WinForms.Colored:

Package Downloads
Bciflex.Brainstorm.Common

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.2.0 242 11/10/2025
3.1.3 5,844 7/13/2025
3.1.2 288 7/7/2025
3.1.1 220 7/3/2025
3.1.0 208 6/30/2025
3.0.1 181 6/28/2025
3.0.0 220 6/21/2025
2.1.2 315 6/6/2025
2.1.0 3,333 3/17/2025
2.0.0 9,302 9/8/2024
1.2.2 5,394 4/15/2024
1.2.1 1,268 3/30/2024
1.2.0 5,008 9/25/2023
1.1.2 10,923 10/16/2022
1.1.1 961 9/9/2022
1.1.0 1,316 6/24/2022
1.0.2 996 6/11/2022
1.0.1 1,013 5/16/2022
1.0.0 1,019 5/9/2022

- Fixed bug with autoscrolling and line limit.

See repository for more information:
https://github.com/vonhoff/Serilog.Sinks.RichTextBox.WinForms.Colored