LiteObservableLogs 1.0.0

dotnet add package LiteObservableLogs --version 1.0.0
                    
NuGet\Install-Package LiteObservableLogs -Version 1.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="LiteObservableLogs" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LiteObservableLogs" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="LiteObservableLogs" />
                    
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 LiteObservableLogs --version 1.0.0
                    
#r "nuget: LiteObservableLogs, 1.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.
#:package LiteObservableLogs@1.0.0
                    
#: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=LiteObservableLogs&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=LiteObservableLogs&version=1.0.0
                    
Install as a Cake Tool

NuGet Actions

LiteObservableLogs

Lightweight observable logging with file output, Serilog-style fluent configuration, and Microsoft.Extensions.Logging integration—fewer moving parts, predictable behavior for desktop and library scenarios.

Features

  • Fluent LoggerConfiguration — chain WriteTo, ObserveTo, Global, MinimumLevel, and Dispatcher similar to common Serilog-style APIs.
  • Microsoft.Extensions.Logging — register via AddLiteObservableLogs (with optional options callback or prebuilt ObservableLoggerOptions).
  • Static Log facadeLog.Information(...), Log.Received, and assignable Log.Logger for quick apps.
  • Multiple sinks — file (rolling by time and/or size), console or Debug, in-process Log.Received, and ObserveTo.Callback with optional per-sink output templates.
  • Global output templateGlobal.OutputTemplate(...) applies when a sink omits its own template (same idea as shared format strings).
  • Runtime tuningLog.Logger.MinimumLevel and Log.Logger.OutputTemplate are get/set and affect subsequent writes without rebuilding the logger.
  • Retention & collision handling — optional retained file count/age; size rolling can back up a conflicting target path to *.bak when the file name template would collide (e.g. missing {Count}).

Usage

Fluent configuration

using LiteObservableLogs;
using System.IO;

string logFile = Path.Combine(AppContext.BaseDirectory, "log", "observable_{Timestamp:yyyyMMdd}_{Count:d5}.log");

Log.Logger = new LoggerConfiguration()
    .WriteTo.File(
        logFile,
        rollingInterval: RollingInterval.Day,
        retainedFileCountLimit: 31,
        retainedFileTimeLimit: TimeSpan.FromDays(21),
        rollingSize: 10240L) // KB threshold for size-based roll
    .WriteTo.Console(target: ConsoleTarget.Debug)
    .ObserveTo.Event()
    .ObserveTo.Callback(e => { /* handle ObservableLogEvent */ }, outputTemplate: null)
    .Global.OutputTemplate("{Timestamp:yyyy-MM-dd HH:mm:ss.fff}|{Level:u5}|{Message}{NewLine}{Exception}")
    .Dispatcher.Async()
    .MinimumLevel.Debug()
    .CreateLogger();

Log.Information("Application started");

Static Log and Log.Received

using LiteObservableLogs;

Log.Received += (_, e) => Console.WriteLine(e.RenderedText);
Log.Warning("Something happened");
Log.CloseAndFlush();

Microsoft.Extensions.Logging host

using LiteObservableLogs.Providers;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

Host.CreateDefaultBuilder(args)
    .ConfigureLogging(builder =>
    {
        builder.ClearProviders();
        builder.AddLiteObservableLogs(options =>
        {
            options.LogFolder = Path.Combine(AppContext.BaseDirectory, "logs");
            options.FileName = "app.log";
            options.MinLevel = LogLevel.Information;
        });
    })
    .Build()
    .Run();

Optional compatibility helper (name only): builder.AddSerilog() maps to current Log options when you already use that pattern elsewhere.

Output templates

  • Per sink — pass outputTemplate on WriteTo.File, WriteTo.Console, ObserveTo.Event, or ObserveTo.Callback.
  • Global fallbackGlobal.OutputTemplate("...") is used when a sink-specific template is omitted or null.
  • Tokens — supports placeholders such as {Timestamp}, {Level}, {Message}, {Exception}, {SourceContext}, {NewLine}, {StackFrames}, caller and thread tokens, etc.

ObserveTo.Event vs ObserveTo.Callback

  • ObserveTo.Event — raises Log.Received with the formatted ObservableLogEvent (same isolation semantics as multicast handlers).
  • ObserveTo.Callback — registers an Action<ObservableLogEvent>; remove with Log.Logger.RemoveCallback(action) when you no longer need it.

Runtime MinimumLevel and OutputTemplate

Log.Logger.MinimumLevel = LogLevel.Warning;
Log.Logger.OutputTemplate = "{Timestamp:O}|{Level:u3}|{Message}";

Changes apply to subsequent log writes (including async formatting where applicable).

File name templates and rolling

  • Use {Timestamp:format} and {Count:format} in WriteTo.File paths for time- and size-based rotation.
  • If size rolling produces the same resolved file name as the active file (for example when {Count} is absent from the template), the library moves the existing file aside as original.log.bak (overwriting an existing .bak) before continuing.

Requirements

  • Target frameworksnet48, netstandard2.0 (see LiteObservableLogs.csproj).
  • DependenciesMicrosoft.Extensions.Logging / Abstractions (versions as referenced by the project).

License

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 117 4/15/2026