TinyLogger 1.9.0

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

// Install TinyLogger as a Cake Tool
#tool nuget:?package=TinyLogger&version=1.9.0

TinyLogger

NuGet Build

Tiny extendable logger that plugins into Microsoft.Extensions.Logging

Because sometimes you don't want to use a full logging framework but still want readable console output and log files.

Simple example

If builder is an instance of ILoggingBuilder you can simply add the console logger like this:

builder.AddTinyConsoleLogger();

More complex example

For more configuration options and file logging, use AddTinyLogger method instead. Checkout the sample ConsoleApp for a complete example.

builder.AddTinyLogger(options =>
{
	// Optionally extend log fields with new or modified data
	options.Extenders.Add(new SampleExceptionExtender());

	// Select a custom message template
	options.Template = MessageTemplates.DefaultTimestamped;

	// Render to console
	options.AddConsole();

	// Render to a file with a set name
	options.AddFile("example.log");

	// Render to file with rolling name, when the timestamp changes the file changes
	options.AddRollingFile(() => $"example-{DateTime.Now.ToString("yyyyMMdd-HHmm")}.log");
});

Screenshot of ConsoleApp sample

Notice the different colors for numbers, strings, dates, uris, easily readable lists and dictionaries, and so on. Colors are selected based on the underlying data type, even in dictionaries.

Sample with TinyLogger Screenshot of sample output with TinyLogger

Sample with standard console logger for comparison Screenshot of sample output with standard console logger

Benefits and drawbacks

Because it is a logger provider like any other you are free to use other loggers as well, TinyLogger won't get in your way. And since it is built on top of the standard logging abstractions from Microsoft there is no magic other than adding the logging provider and the simple configuration.

How it works

When a log message is received it is passed to an internal message tokenizer which parses the original log format, extracts data from the log message state and creates a list of message tokens which easily can be rendered by any class implementing the ILogRenderer interface.

The console renderer will render tokens containing object values with different colors depending on their type so logs easier to read, while the file logger will render in plain text.

If you want one log format for the console and one log format for files, you can simply add two instances of TinyLogger with different configuration options.

Background workers

Everything is rendered on background threads to be as non blocking as possible.

This however means that messages are temporarily stored on a queue until they are ready to be processed by a log renderer, which should normally be nearly instantly. But if log messages are produced faster than can be rendered then eventually you may hit the configurable queue depth limit.

If this happens a decision has to be made whether to keep all messages in which case logging threads will be blocked until the log renderers can catch up, or start discarding messages to give renderers more breathing room.

The default behavior is to keep all messages.

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. 
.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 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  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.9.0 4,916 11/19/2023
1.8.7 177 9/15/2023
1.8.6 8,165 6/16/2023
1.8.5 169 4/14/2023
1.8.4 231 3/17/2023
1.8.3 234 2/15/2023
1.8.2 7,629 1/11/2023
1.8.1 275 12/17/2022
1.8.0 339 11/11/2022
1.7.0 429 9/4/2022
1.6.1 10,836 6/8/2022
1.6.0 8,643 11/13/2021
1.5.2 327 8/16/2021
1.5.1 319 4/26/2021
1.5.0 305 4/25/2021
1.4.1 332 2/6/2021
1.4.0 394 12/7/2020
1.3.0 439 7/7/2020
1.2.1 521 3/31/2020
1.2.0 483 12/15/2019
1.1.0 509 12/10/2019
1.0.0 482 12/2/2019