Oakrey.Applications.Log 4.0.4

dotnet add package Oakrey.Applications.Log --version 4.0.4
                    
NuGet\Install-Package Oakrey.Applications.Log -Version 4.0.4
                    
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="Oakrey.Applications.Log" Version="4.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Oakrey.Applications.Log" Version="4.0.4" />
                    
Directory.Packages.props
<PackageReference Include="Oakrey.Applications.Log" />
                    
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 Oakrey.Applications.Log --version 4.0.4
                    
#r "nuget: Oakrey.Applications.Log, 4.0.4"
                    
#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.
#:package Oakrey.Applications.Log@4.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Oakrey.Applications.Log&version=4.0.4
                    
Install as a Cake Addin
#tool nuget:?package=Oakrey.Applications.Log&version=4.0.4
                    
Install as a Cake Tool

Oakrey.Applications.Log

A .NET 10 library that integrates Oakrey logging into Windows applications via IServiceCollection extension methods. It provides a WpfQueueLogger-backed view model for real-time UI log visualization, settings-persisted log level filtering, and a preloadable cleanup service that removes log files older than 7 days.


Main features

  • ConfigureLoggingServices � initializes LoggerFactory basic loggers and registers ILogger<T> / LoggerProxy<T> as singletons in the DI container.
  • ConfigureLogViewServices � registers a WpfQueueLogger singleton (queue capacity 100) and a transient LogViewModel for WPF binding.
  • LogViewModel � bindable view model exposing WpfQueueLogger, a settings-persisted DisplayLogLevel (Level.Information default), and a settings-persisted VerticalOffsetValue. Includes a design-time constructor that pre-populates sample log entries.
  • LogFileCleanupService � implements IPreLoadable and IDisposable. On Preload(), deletes .log files older than 7 days from Documents\<AppName>\Logs. Reports failures as PreLoadingException via IObservable<PreLoadingException> backed by a ReplaySubject.
  • ILogConfig � interface for decoupled access to DisplayLogLevel and VerticalOffsetValue.

Architecture

classDiagram
    class LoggingConfigurationExtension {
        +AddOakreyLogging(IServiceCollection) IServiceCollection
        +ConfigureLoggingServices(IServiceCollection) IServiceCollection
        +ConfigureLogViewServices(IServiceCollection) IServiceCollection
    }

    class LogViewModel {
        +WpfLogger : WpfQueueLogger
        +DisplayLogLevel : Level
        +VerticalOffsetValue : double
    }

    class LogFileCleanupService {
        +Preload(CancellationToken) Task
        +Subscribe(IObserver) IDisposable
        +Dispose()
    }

    class ILogConfig {
        <<interface>>
        +DisplayLogLevel : Level
        +VerticalOffsetValue : double
        +GetValue~T~(string) T
    }

    class ILogFileCleanupService {
        <<interface>>
    }

    LogViewModel ..|> INotifyPropertyChanged
    LogViewModel ..|> ILogConfig
    LogFileCleanupService ..|> ILogFileCleanupService
    LogFileCleanupService ..|> IPreLoadable
    LogFileCleanupService ..|> IDisposable
    LoggingConfigurationExtension --> LogViewModel : registers
    LoggingConfigurationExtension --> WpfQueueLogger : registers

Requirements

  • .NET 10 (net10.0-windows)
  • Windows
  • Dependencies: Oakrey.Applications.Settings, Oakrey.Log, Oakrey.Log.Windows

Installation

.NET CLI

dotnet add package Oakrey.Applications.Log

Package Manager Console

Install-Package Oakrey.Applications.Log

NuGet Package Manager in Visual Studio

Navigate to Tools > NuGet Package Manager > Manage NuGet Packages for Solution, search for Oakrey.Applications.Log, and install.


Usage

Registering logging services

Call both methods during application startup, typically in your DI composition root:

services
    .ConfigureLoggingServices()   // registers ILogger<T>, initializes LoggerFactory
    .ConfigureLogViewServices();  // registers WpfQueueLogger + LogViewModel

AddOakreyLogging() is also available as a standalone call when you only need ILogger<T> registration without reinitializing LoggerFactory.

Binding LogViewModel in WPF


<ItemsControl ItemsSource="{Binding WpfLogger.Entries}">
    ...
</ItemsControl>

<ComboBox SelectedItem="{Binding DisplayLogLevel}" />
// inject via DI
public LogView(LogViewModel viewModel)
{
    DataContext = viewModel;
    InitializeComponent();
}

Registering the cleanup service

services.AddSingleton<ILogFileCleanupService, LogFileCleanupService>();

Then call Preload during application startup (or via the IPreLoadable pipeline):

await logFileCleanupService.Preload(cancellationToken);

Subscribe to failures if you want to surface them in the UI:

logFileCleanupService.Subscribe(ex =>
{
    // ex.Message, ex.Detail, ex.InnerException available
});

Using ILogConfig

public class MyService(ILogConfig logConfig)
{
    public void Apply()
    {
        Level level = logConfig.DisplayLogLevel;
    }
}

Development notes

  • Log file path � files are deleted from Environment.SpecialFolder.MyDocuments\<IApplicationInfo.Name>\Logs. The application name is resolved via the injected IApplicationInfo.
  • Retention period � hardcoded to 7 days (TimeSpan(7, 0, 0, 0)). There is currently no configuration API for this value.
  • Design-time supportLogViewModel has a parameterless constructor that seeds sample entries at Information, Debug, and Error levels, enabling XAML designer previews without DI.
  • ReplaySubjectLogFileCleanupService uses ReplaySubject<PreLoadingException> so late subscribers still receive exceptions that occurred before they subscribed. Dispose the service to release it.

Project information

Field Value
Package ID Oakrey.Applications.Log
Author Oakrey
License MIT
Repository ApplicationServices
Project URL oakrey.cz
NuGet Oakrey.Applications.Log
Product Compatible and additional computed target framework versions.
.NET net10.0-windows7.0 is compatible. 
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

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.4 47 5/15/2026
4.0.3 119 3/13/2026
4.0.2 132 2/13/2026
4.0.1 129 2/11/2026
4.0.0 445 11/18/2025
3.0.1 202 10/31/2025
3.0.0 212 10/22/2025
2.0.2 189 10/10/2025
2.0.1 249 9/29/2025
2.0.0 394 6/11/2025
1.0.0 295 4/17/2025