Serilog.Sinks.RichTextBox.WinForms.Colored 2.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Serilog.Sinks.RichTextBox.WinForms.Colored --version 2.1.2
                    
NuGet\Install-Package Serilog.Sinks.RichTextBox.WinForms.Colored -Version 2.1.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="2.1.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="2.1.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 2.1.2
                    
#r "nuget: Serilog.Sinks.RichTextBox.WinForms.Colored, 2.1.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.
#addin nuget:?package=Serilog.Sinks.RichTextBox.WinForms.Colored&version=2.1.2
                    
Install as a Cake Addin
#tool nuget:?package=Serilog.Sinks.RichTextBox.WinForms.Colored&version=2.1.2
                    
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
  • Dark and Light theme presets with customization options
  • Auto-scrolling to latest messages
  • Line limiting to control memory usage

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: 200,
        messagePendingInterval: 16,
        autoScroll: true,
        maxLogLines: 512)
    .CreateLogger();

Themes

Available built-in themes:

Theme Description
ThemePresets.Dark A dark theme inspired by modern IDEs and the Serilog Console sink.
ThemePresets.Light A light theme with vibrant colors and high contrast for optimal readability.
ThemePresets.DarkClassic A theme replicating the Serilog Console sink.
ThemePresets.LightClassic A theme with a light background and contrasting colors.

You can customize the themes by creating your own theme instance or modifying the existing ones. The themes support various style tokens for different parts of the log message, including:

  • Text colors for different log levels
  • Syntax highlighting for strings, numbers, and booleans
  • Background colors for error and fatal messages
  • Custom styling for null values and invalid content

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.

Why use a WinForms RichTextBox instead of a WPF RichTextBox?

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

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

This project is licensed 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.1.0 5 6/30/2025
3.0.1 15 6/28/2025
3.0.0 115 6/21/2025
2.1.2 191 6/6/2025
2.1.0 2,005 3/17/2025
2.0.0 8,721 9/8/2024
1.2.2 5,279 4/15/2024
1.2.1 1,194 3/30/2024
1.2.0 4,810 9/25/2023
1.1.2 9,994 10/16/2022
1.1.1 869 9/9/2022
1.1.0 1,216 6/24/2022
1.0.2 890 6/11/2022
1.0.1 919 5/16/2022
1.0.0 912 5/9/2022

Public Changes:
- Replaced themes with newly designed themes.
- Moved old themes to "DarkClassic" and "LightClassic".
- Fixed bugs with the formatters (JSON and Literal).
- Changed the default configuration for optimal performance.
- Removed link detection, as it causes issues with the formatting.
- Updated TargetFrameworks to include net9.0-windows, netcoreapp3.1-windows, and netcoreapp3.0-windows.

Internal Changes:
- Removed useless code and cleaned up the project.
- Replaced ConcurrentQueue with a BlockingCollection in the sink.

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