logfmt.net 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package logfmt.net --version 0.2.0
                    
NuGet\Install-Package logfmt.net -Version 0.2.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="logfmt.net" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="logfmt.net" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="logfmt.net" />
                    
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 logfmt.net --version 0.2.0
                    
#r "nuget: logfmt.net, 0.2.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 logfmt.net@0.2.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=logfmt.net&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=logfmt.net&version=0.2.0
                    
Install as a Cake Tool

Logfmt.net

Project Intro

logfmt.net is intended to be a simple & lightweight structured logging library for .net applications.

Goals:

  • Support the logfmt output format.
  • Enable the practice of structured logging.
  • Provide space delimited or json encoding of output.
  • Sending output to default console stream or any other provided stream.

Non-Goals:

  • Managing file rollovers
  • Data routing rules & filters
  • Output templates

Installation

Binary distribution of this library is available in a nuget package. Run the following command to install it:

dotnet add package logfmt.net --version 0.0.4-alpha

Note: this requires the .NET CLI tool. Other installation methods for nuget packages are available on the package page @ https://www.nuget.org/packages/logfmt.net

Building the source

Running make all in a shell from the root directory of this repository will build the library and execute the tests. It uses the dotnet command, so the .NET CLI tool must be installed.

Using the library

To use the logfmt logger, create a new instance of the Logger class:

var log = new logfmt.Logger();
log.Info("hello logs!");

The default contructor will send the log output to the console output stream. There is an overload for the constructor to provide a different stream to send output to.

All of the severity log methods (Debug,Info,Warn,Error) accept KeyValuePair<string,string> params in addition to the log message. This enables the logging of structured data outside of the log message string.

var log = new logfmt.Logger();
log.Info("hello logs!", new KeyValuePair<string,string>("foo","bar"),new KeyValuePair<string,string>("bar","foo"));

If there is a key value pair that is needed on every logging call, the WithData method can register it for all future calls in the instance.

var log = new logfmt.Logger().WithData(new KeyValuePair<string,string>("foo","bar"));
// the Info call below will have foo=bar added to the output 
log.Info("hello logs!");

Contributions

Contributions are welcomed & encouraged! If there is something missing or broken please feel free to write an issue, or submit a PR.

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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 was computed.  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. 
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 167 3/22/2026
0.4.1 93 3/19/2026
0.4.0 208 12/4/2025
0.3.0 694 12/2/2025
0.2.0 269 8/18/2025
0.1.2-alpha 160 6/25/2024
0.1.1-alpha 138 5/2/2024
0.0.4-alpha 2,831 11/12/2021
0.0.3-alpha 389 9/9/2021
0.0.2-alpha 789 7/12/2019

- Now supports net8.0    
     - Added support for default data pairs to be included on every log output.
     - Output of log data to console (default) or specified stream.
     - Severity levels (DEBUG, INFO, WARN, ERROR).
     - Data properties on logging methods as KeyValuePairs.
     - Added support for Microsoft.Extensions.Logging interfaces.
     - Added support for OpenTelemetry Logging.
     - Added handling of values containing line breaks.
     - Added OpenTelemetry support for logfmt format.