Serilog.Sinks.RichTextBox.WinForms.Colored 3.0.0

dotnet add package Serilog.Sinks.RichTextBox.WinForms.Colored --version 3.0.0
                    
NuGet\Install-Package Serilog.Sinks.RichTextBox.WinForms.Colored -Version 3.0.0
                    
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="3.0.0" />
                    
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="3.0.0" />
                    
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 3.0.0
                    
#r "nuget: Serilog.Sinks.RichTextBox.WinForms.Colored, 3.0.0"
                    
#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.
#addin nuget:?package=Serilog.Sinks.RichTextBox.WinForms.Colored&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Serilog.Sinks.RichTextBox.WinForms.Colored&version=3.0.0
                    
Install as a Cake Tool

Serilog.Sinks.RichTextBox.WinForms.Colored

NuGet Downloads workflow Latest version License

A Serilog sink that writes log events to a WinForms RichTextBox with support for coloring and custom themes.

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

Features

  • Colored log events in a WinForms RichTextBox control
  • Multiple theme presets with customization options
  • High-performance asynchronous processing
  • Line limit to control memory usage
  • WCAG compliant color schemes based on the Serilog WPF RichTextBox sink.

Get Started

Install the package from NuGet:

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

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("Cascadia Mono", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
    this.richTextBox1.Location = new System.Drawing.Point(0, 0);
    this.richTextBox1.Name = "richTextBox1";
}

Configure the logger to use the sink using the RichTextBox extension method:

Log.Logger = new LoggerConfiguration()
    .WriteTo.RichTextBox(richTextBox1, theme: ThemePresets.Literate)
    .CreateLogger();

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

See the Extension Method for more configuration options.

Themes

Available built-in themes:

Theme Description
ThemePresets.Literate Styled to replicate the default theme of Serilog.Sinks.Console (default)
ThemePresets.Grayscale A theme using only shades of gray, white, and black
ThemePresets.Colored A theme based on the original Serilog.Sinks.ColoredConsole sink
ThemePresets.Luminous A light theme with high contrast for accessibility

The themes based on the original sinks are slightly adjusted to be WCAG compliant, ensuring that the contrast ratio between text and background colors is at least 4.5:1.

You can create your own custom themes by creating a new instance of the Theme class and passing it to the RichTextBox extension method. Look at the existing themes for examples.

Frequently Asked Questions

Why is the package name so long?

Shorter alternatives were already reserved in the NuGet registry, so a more descriptive name was needed for this implementation. The name is a bit long, but it makes it easier to find the package in the NuGet registry.

Why use a WinForms RichTextBox instead of a WPF RichTextBox?

This sink is specifically designed for WinForms applications to avoid the WPF framework. Using a WPF-based logging component would require adding the entire WPF framework with all its dependencies, greatly increasing the size of the application.

Support and Contribute

If you find value in this project, there are several ways you can contribute:

  • Give the project a star on GitHub ⭐
  • Support the project through GitHub Sponsors
  • Improve documentation, report bugs, or submit pull requests

License

Copyright © 2025 Simon Vonhoff & Contributors - Provided under the Apache License, Version 2.0.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net6.0-windows7.0 is compatible.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net9.0-windows7.0 is compatible.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 is compatible.  netcoreapp3.1 is compatible. 
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 is compatible.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.0

  • .NETCoreApp 3.1

  • .NETFramework 4.6.2

  • .NETFramework 4.7.1

  • net6.0-windows7.0

  • net8.0-windows7.0

  • net9.0-windows7.0

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 61 6/21/2025
2.1.2 183 6/6/2025
2.1.0 1,936 3/17/2025
2.0.0 8,713 9/8/2024
1.2.2 5,274 4/15/2024
1.2.1 1,190 3/30/2024
1.2.0 4,803 9/25/2023
1.1.2 9,977 10/16/2022
1.1.1 867 9/9/2022
1.1.0 1,214 6/24/2022
1.0.2 888 6/11/2022
1.0.1 916 5/16/2022
1.0.0 909 5/9/2022

- Reduced configurable options to only the most relevant ones (breaking change).
- Aligned theme colors with Serilog WPF sink including WCAG compliance (breaking change).
- Fixed UI freeze caused by SystemEvents on background-thread RichTextBox.
- Optimized performance by removing the off-screen RichTextBox and improving rendering logic.
- Fixed auto-scroll issue on .NET Framework.

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