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                
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.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Sinks.RichTextBox.WinForms.Colored --version 2.0.0                
#r "nuget: Serilog.Sinks.RichTextBox.WinForms.Colored, 2.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.
// 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

NuGet Downloads 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

  • 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.5.2

  • net6.0-windows7.0

  • net8.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
2.0.0 3,464 9/8/2024
1.2.2 5,038 4/15/2024
1.2.1 1,166 3/30/2024
1.2.0 4,324 9/25/2023
1.1.2 8,543 10/16/2022
1.1.1 836 9/9/2022
1.1.0 1,168 6/24/2022
1.0.2 850 6/11/2022
1.0.1 875 5/16/2022
1.0.0 858 5/9/2022

- 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