Bleess.Extensions.Logging.File 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Bleess.Extensions.Logging.File --version 1.0.0                
NuGet\Install-Package Bleess.Extensions.Logging.File -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="Bleess.Extensions.Logging.File" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bleess.Extensions.Logging.File --version 1.0.0                
#r "nuget: Bleess.Extensions.Logging.File, 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.
// Install Bleess.Extensions.Logging.File as a Cake Addin
#addin nuget:?package=Bleess.Extensions.Logging.File&version=1.0.0

// Install Bleess.Extensions.Logging.File as a Cake Tool
#tool nuget:?package=Bleess.Extensions.Logging.File&version=1.0.0                

Bleess.Extensions.Logging.File

Simple rolling file logger for Microsoft.Extensions.Logging with no 3rd party dependencies

Very similar implementation to other standard MS logging providers such as Console Logger in dotnet 5.

Features include

  • Text or Json output
  • Rolling files
  • Standard Microsoft.Extensions.Logging configuration (similar to Console logging, etc)
  • Plugable custom formatters
  • Abitity to change settings while running (using IOptionsMonitor)
  • Logging scopes
  • High performance using dedicated write thread and message queue

This project is very similar to nReco/logging with a few additions noteably logging scopes, json output, streamlined configuration, and abiltity to modify settings while running.

Usage

The log provider is configured just like any other Microsoft.Extensions.Logging providers. There are extensions methods on the ILogBuilder to add the provider.

When using Host.CreateDefaultBuilder you only need to call AddFile(), and the logger will be configured using configuration providers. There are also other overloads to configure the logger using options callbacks etc.

logBuilder.AddFile();

Configuration

Below is a sample configuration for the file provider. The values shown are the defaults.

{
  "Logging": {

    "File": {
      "IncludeScopes": true,
      "Path": "logs/log.txt",
      "MaxNumberFile": 7,
      "MaxFileSizeInMB": 50,  // this can be decimal
      "FormatterName": "simple",  // simple or json
      "Append": true,
      "logLevel": {
        "default": "Information"
      }
    },

    "logLevel": {
      "default": "Information"
    }
  }
}

Formatting

There are two built in formatters. Simple text and Json. The formatters have a few limited options.

TODO: Document formatter configuration

Custom formatters can be plugged in the same way as with Console Logger in dotnet 5.

Rolling Behavior

Log files can have a max file size at which time a new file will be create with a increment id. You can also specify a maximum nuber of files to retain. Once the maximum number of files has been reteached the oldest will be overwritten.

Credits

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 3,634 1/23/2024
2.0.0 138 1/20/2024
2.0.0-rc2 128 1/18/2024
2.0.0-rc1 94 1/16/2024
1.0.0 14,454 9/26/2020

How to use: https://github.com/pableess/Bleess.Extensions.Logging.File

     Initial Release 1.0.0
      - Basic file logging features: rolling files, maximum file length, max number of files, etc
      - Simple text and json formatters with options for single line, multi-line, and separated log statements
      - Support for logging scopes
      - Support for idiomatic microsoft.extensions.logging configuration
      - Ability to reconfigure/change settings without restarting application
      - Asynchronous log file writing for high log throughput and performance
      - Current support for ms.extensions 3.x and greater