TinyLogger 1.6.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package TinyLogger --version 1.6.1                
NuGet\Install-Package TinyLogger -Version 1.6.1                
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.6.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TinyLogger --version 1.6.1                
#r "nuget: TinyLogger, 1.6.1"                
#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.6.1

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

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.

For production scenarios you should probably use a more full featured logging framework since they tend to be battle tested. TinyLogger is more intended for development scenarios and as such does not have as many features, but that's why it's tiny.

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 is compatible.  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 was computed.  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 was computed.  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 (1)

Showing the top 1 popular GitHub repositories that depend on TinyLogger:

Repository Stars
steamcore/TinyIpc
.NET inter process broadcast message bus with supporting classes
Version Downloads Last updated
3.0.0 61 11/23/2024
2.0.2 146 11/1/2024
2.0.1 206 7/9/2024
2.0.0 164 5/18/2024
1.9.0 17,093 11/19/2023
1.8.7 208 9/15/2023
1.8.6 8,199 6/16/2023
1.8.5 202 4/14/2023
1.8.4 267 3/17/2023
1.8.3 261 2/15/2023
1.8.2 7,663 1/11/2023
1.8.1 309 12/17/2022
1.8.0 368 11/11/2022
1.7.0 459 9/4/2022
1.6.1 10,865 6/8/2022
1.6.0 8,676 11/13/2021
1.5.2 342 8/16/2021
1.5.1 352 4/26/2021
1.5.0 336 4/25/2021
1.4.1 361 2/6/2021
1.4.0 420 12/7/2020
1.3.0 471 7/7/2020
1.2.1 544 3/31/2020
1.2.0 510 12/15/2019
1.1.0 538 12/10/2019
1.0.0 507 12/2/2019