Serilog.Sinks.RichTextBoxEx.Wpf 1.1.0

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.RichTextBoxEx.Wpf --version 1.1.0                
NuGet\Install-Package Serilog.Sinks.RichTextBoxEx.Wpf -Version 1.1.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.RichTextBoxEx.Wpf" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Sinks.RichTextBoxEx.Wpf --version 1.1.0                
#r "nuget: Serilog.Sinks.RichTextBoxEx.Wpf, 1.1.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.RichTextBoxEx.Wpf as a Cake Addin
#addin nuget:?package=Serilog.Sinks.RichTextBoxEx.Wpf&version=1.1.0

// Install Serilog.Sinks.RichTextBoxEx.Wpf as a Cake Tool
#tool nuget:?package=Serilog.Sinks.RichTextBoxEx.Wpf&version=1.1.0                
README.md

<div align="center">

<img src="asset/serilog-sink-nuget.png" alt="Serilog.Sinks.RichTextBox.Wpf" width="100" />

</div>

<h1 align="center">Serilog.Sinks.RichTextBoxEx.Wpf</h1> <div align="center">

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

NuGet Version .NET .NET Core .NET Framework Stack Overflow

Screenshot of Serilog.Sinks.RichTextBox.Wpf in action

</div>

Give a Star! ⭐

If you like or are using this project please give it a star. Thanks!

Getting started πŸš€

Install the Serilog.Sinks.RichTextBox.Wpf package from NuGet:

Install-Package Serilog.Sinks.RichTextBox.Wpf -Prerelease

Declare your RichTextBox control and give it a name that you can reference it from the code-behind. e.g.:

<Window (...)>
  <RichTextBox
      x:Name="MyRichTextBox"
      Background="Black"
      Foreground="LightGray"
      FontFamily="Cascadia Mono, Consolas, Courier New, monospace"
      VerticalScrollBarVisibility="Auto"
  />
</Window>

Then enable the sink using WriteTo.RichTextBox():

Log.Logger = new LoggerConfiguration()
    .WriteTo.RichTextBox(MyRichTextBox)
    .CreateLogger();

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

Log events will be written to the RichTextBox control:

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

Themes

The sink will colorize output by default:

Screenshot of Serilog.Sinks.RichTextBox.Wpf in action

Themes can be specified when configuring the sink:

    .WriteTo.RichTextBox(MyRichTextBox, theme: RichTextBoxConsoleTheme.Grayscale)

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

Theme Description
RichTextBoxTheme.None No styling. Uses default styles applied to the RichTextBox control
RichTextBoxConsoleTheme.Literate Styled to replicate the default theme of Serilog.Sinks.Console; This is the default when no theme is specified
RichTextBoxConsoleTheme.Grayscale A theme using only shades of gray, white, and black
RichTextBoxConsoleTheme.Colored A theme based on the original Serilog.Sinks.ColoredConsole sink

Adding a new theme is straightforward; examples can be found in the RichTextBoxConsoleThemes class.

Output templates

The format of events to the RichTextBox can be modified using the outputTemplate configuration parameter:

    .WriteTo.RichTextBox(MyRichTextBox,
        outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")

The default template, shown in the example above, uses built-in properties like Timestamp and Level. Properties from events, including those attached using enrichers, can also appear in the output template.

Release History

Click on the Releases tab on GitHub.


Copyright Β© 2021-2023 C. Augusto Proiete & Contributors - Provided under the Apache License, Version 2.0.

Product Compatible and additional computed target framework versions.
.NET net5.0-windows7.0 is compatible.  net6.0-windows was computed.  net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net7.0-windows7.0 is compatible.  net8.0-windows was computed.  net8.0-windows7.0 is compatible. 
.NET Framework net462 is compatible.  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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Serilog.Sinks.RichTextBoxEx.Wpf:

Repository Stars
babalae/better-genshin-impact
📦BetterGI · ζ›΄ε₯½ηš„εŽŸη₯ž - θ‡ͺεŠ¨ζ‹Ύε– | θ‡ͺεŠ¨ε‰§ζƒ… | ε…¨θ‡ͺεŠ¨ι’“ι±Ό(AI) | ε…¨θ‡ͺεŠ¨δΈƒεœ£ε¬ε”€ | θ‡ͺ动伐木 | θ‡ͺ动刷本 | θ‡ͺεŠ¨ι‡‡ι›† - UI Automation Testing Tools For Genshin Impact
Version Downloads Last updated
1.1.0.1 1,307 7/12/2024
1.1.0 77 7/12/2024