DecSm.Extensions.Logging.File 1.7.0-rc.4

This is a prerelease version of DecSm.Extensions.Logging.File.
dotnet add package DecSm.Extensions.Logging.File --version 1.7.0-rc.4
                    
NuGet\Install-Package DecSm.Extensions.Logging.File -Version 1.7.0-rc.4
                    
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="DecSm.Extensions.Logging.File" Version="1.7.0-rc.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DecSm.Extensions.Logging.File" Version="1.7.0-rc.4" />
                    
Directory.Packages.props
<PackageReference Include="DecSm.Extensions.Logging.File" />
                    
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 DecSm.Extensions.Logging.File --version 1.7.0-rc.4
                    
#r "nuget: DecSm.Extensions.Logging.File, 1.7.0-rc.4"
                    
#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 DecSm.Extensions.Logging.File@1.7.0-rc.4
                    
#: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=DecSm.Extensions.Logging.File&version=1.7.0-rc.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=DecSm.Extensions.Logging.File&version=1.7.0-rc.4&prerelease
                    
Install as a Cake Tool

DecSm.Extensions.Logging.File

Build Validate

A simple file logger provider for Microsoft.Extensions.Logging.

Installation

To install the package, run the following command in the Package Manager Console:

Install-Package DecSm.Extensions.Logging.File

Usage

Add the file logger to your ILoggingBuilder in your Program.cs or Startup.cs:

Basic Usage

builder.Logging.AddFile();

This will register the file logger with the default options. A new log file will be created in the Logs directory of your application's root.

Buffered vs. Direct Logging

The AddFile method has an optional buffered parameter that defaults to true.

  • Buffered (Default): Logs are written to an in-memory channel and processed by a background service. This is the recommended approach for most applications as it minimizes the performance impact on your application.
  • Direct: Logs are written directly to the file system. This is useful for console applications or scenarios where you want to ensure logs are written immediately.

To use direct logging, set the buffered parameter to false:

builder.Logging.AddFile(buffered: false);

Advanced Configuration

You can configure the file logger by passing an action to the AddFile method:

builder.Logging.AddFile(options =>
{
    options.LogDirectory = "MyLogs";
    options.LogName = "my-app";
    options.FileSizeLimitBytes = 10 * 1024 * 1024; // 10 MB
    options.RolloverInterval = FileRolloverInterval.Hour;
    options.MaxTotalSizeBytes = 1024 * 1024 * 1024; // 1 GB
});

Per-Level Log Files

You can also specify a different log file for each log level:

builder.Logging.AddFile(options =>
{
    options.PerLevelLogName = new()
    {
        [LogLevel.Information] = "info",
        [LogLevel.Warning] = "warn",
        [LogLevel.Error] = "error",
    };
});

This will create separate log files for Information, Warning, and Error level logs. All other log levels will be logged to the default log file.

Configuration Options

Option Description Default
LogDirectory The directory to store log files in. Logs
LogName The base name for log files. If not specified, the application name will be used. null
PerLevelLogName A dictionary to specify a different log file for each log level. []
FileSizeLimitBytes The maximum size of a single log file in bytes. 104857600 (100 MB)
RolloverInterval The interval at which to create a new log file. FileRolloverInterval.Day
MaxTotalSizeBytes The maximum total size of all log files in bytes. 10737418240 (10 GB)

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

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 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 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  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.7.0-rc.4 56 1/5/2026
1.7.0-rc.2 53 12/30/2025
1.6.0 273 12/18/2025
1.6.0-rc.2 228 12/18/2025
1.5.1-rc.1 228 12/18/2025
1.5.0-rc.24 225 12/18/2025
1.5.0-rc.22 229 12/17/2025
1.5.0-rc.12 192 9/22/2025
1.5.0-rc.10 190 9/22/2025
1.5.0-rc.8 144 9/9/2025
1.5.0-rc.6 146 9/9/2025
1.5.0-rc.4 144 9/9/2025
1.5.0-rc.2 129 8/24/2025
1.4.0 572 7/23/2025
1.4.0-rc.2 533 7/23/2025
1.3.0 576 7/23/2025
1.3.0-rc.7 532 7/23/2025
1.3.0-rc.4 142 6/24/2025
1.3.0-rc.2 143 6/16/2025
1.2.0 124 6/7/2025
Loading failed