Here is a GIF with default colorization for the WinForms version in C#, using Dependency Injection and data-binding: The WPF, WinForms, and Avalonia versions of the LogViewerControl look almost identical and work the same for both the C# & VB versions. Previewīefore we get started, let's look at what we want to achieve. 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. We will be looking into Logging - how it works and look at the framework code that makes it work.Īs we will be covering WPF, WinForms, and Avalonia project types, Microsoft and Serilog loggers, and also using / not using Dependency Injection, this article will be a bit lengthy. AppSettings.Json file support for configurable logging.Selectable auto-scrolling to keep the latest entry visible.History viewable in any list control, a ListView / DataGrid control.MVVM (Model View ViewModel design pattern) and non-MVVM usage.Dependency Injection (DI) and non-DI usage.Support colorization (custom colors as a bonus).Support multiple Logging Frameworks - Microsoft (default), Serilog, and NLog. Support multiple Operating Systems - Windows, MacOS, Linux.Native for WinForms, WPF, and Avalonia applications.Defined as a control that could be added or injected via dependency injection.The requirements for the LoggerViewer are: 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 - i.e., User Friendly, not the following: 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. Download LogViewerControl_v1.00 - 7.2MB - 7.2 MB.Download LogViewerControl_v1.10 - 8MB - 8 MB.Download LogViewerControl_v1.20 - 7.4MB - 7.4 MB.
0 Comments
Leave a Reply. |