LogViewerControl
Real-time log viewer control for .NET applications supporting WinForms, WPF, and Avalonia. Features live colorized logging, cross-platform compatibility, and works with Microsoft Logger, Serilog, NLog, and Log4Net. Easy integration with dependency injection support.
Install / Use
/learn @gragra33/LogViewerControlREADME
Dot Net Core LogViewer Control for WinForms, Wpf, and Avalonia using the ILogger Framework with Microsoft Logger, Serilog, NLog, and Log4Net in C# & VB on Windows, Mac OS, and Linux
WinForms, WPF, and Avalonia LogViewer controls for live viewing of ILogger entries with full colorization support, and more for C# and VB on Windows, MacOS and Linux using Microsoft Logger, Serilog, NLog, and Log4Net + Logging Demystified
Introduction
I was working on a solution that required a Viewer for Logger entries in the app itself for live viewing of what was happening behind the scene.
I wanted something prettier than the console output and something that could be added to a Winforms, WPF, or Avalonia application that felt part of the application, and possibly something that a user may need to view - ie: User Friendly, not the following:

The requirements for the LoggerViewer are:
- Defined as a control that could be added or injected via dependency injection
- Native for WinForms, WPF, and Avalonia applications
- Support multiple Operating Systems - Windows, MacOS, Linux
- Support multiple Logging Frameworks - Microsoft (default), Serilog, NLog, and Log4Net
- Support colorization (custom colors as a bonus)
- Dependency Injection (DI) and non-DI usage
- MVVM (Model View ViewModel design pattern) and non-MVVM usage
- History viewable in any list control, a
ListView/DataGridcontrol - Selectable auto-scrolling to keep the latest entry visible
- AppSettings.Json file support for configurable logging
- Capture framework API logging
- Work in parallel with other Loggers
We will be looking into Logging - how it works and look at the framework code that makes it work.
As we will be covering WPF, WinForms, and Avalonia project types, Microsoft, Serilog, and NLog loggers, and also using / not using Dependency Injection, this article will be a bit lengthy.
If you are not interested in how it all works, then see the animations in the Preview section below, download the code, and run the application(s) that are applicable to your use case in the language that you work in.
Preview
Before we get started, let's look at what we want to achieve. The WPF, WinForms, and Avalonia versions of the LogViewerControl look almost identical and work the same for both the C# & VB versions.
Here is a GIF with default colorization for the WinForms version in C#, using Dependency Injection and data-binding:

Here is a GIF with custom colorization for the WPF version, minimal implementation in VB, no Dependency injection, 3 lines of code:

Lastly, here is proof that you can develop an application for Mac OS using VB, yes Visual Basic, using the Avalonia Framework! Whilst VB is not supported out-of-the-box, as there are no included Application, Class, or Control library templates with the exception of a Github repository that is not complete, I will cover how to get VB to use the Avalonia framework for both application and control project types.

Note: The 3 animated GIFs may take a moment to load...
Contents
<!-- TOC -->- Introduction
- Preview
- Contents
- Prerequisites
- Solution Setup
- How Does Logging Work?
- Custom Loggers
- Shared Logging Data
- Custom Microsoft Logger Implementation
- Custom Serilog Logger Implementation
- Custom NLog Target Logger Implementation
- Custom Apache Log4Net Appender Logger Implementation
- Processing Log Entries
- LogViewerControl Implementation
- Using the LogViewControl
Related Skills
openhue
349.2kControl Philips Hue lights and scenes via the OpenHue CLI.
sag
349.2kElevenLabs text-to-speech with mac-style say UX.
weather
349.2kGet current weather and forecasts via wttr.in or Open-Meteo
tradingview-mcp
682Advanced TradingView MCP Server for AI-powered market analysis. Real-time crypto & stock screening, technical indicators, Bollinger Band intelligence, and candlestick patterns. Works with Claude Desktop & AI assistants. Multi-exchange support (Binance, KuCoin, Bybit+). Open source trading toolkit.
