DecSm.Extensions.Logging.File
1.7.0-rc.4
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
<PackageReference Include="DecSm.Extensions.Logging.File" Version="1.7.0-rc.4" />
<PackageVersion Include="DecSm.Extensions.Logging.File" Version="1.7.0-rc.4" />
<PackageReference Include="DecSm.Extensions.Logging.File" />
paket add DecSm.Extensions.Logging.File --version 1.7.0-rc.4
#r "nuget: DecSm.Extensions.Logging.File, 1.7.0-rc.4"
#:package DecSm.Extensions.Logging.File@1.7.0-rc.4
#addin nuget:?package=DecSm.Extensions.Logging.File&version=1.7.0-rc.4&prerelease
#tool nuget:?package=DecSm.Extensions.Logging.File&version=1.7.0-rc.4&prerelease
DecSm.Extensions.Logging.File
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 | Versions 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. |
-
.NETFramework 4.8
- JetBrains.Annotations (>= 2025.2.4)
- Microsoft.Bcl.TimeProvider (>= 10.0.1)
- Microsoft.Extensions.Logging.Configuration (>= 10.0.1)
- System.IO.Abstractions (>= 22.1.0)
- System.Threading.Channels (>= 10.0.1)
-
.NETStandard 2.0
- JetBrains.Annotations (>= 2025.2.4)
- Microsoft.Bcl.TimeProvider (>= 10.0.1)
- Microsoft.Extensions.Logging.Configuration (>= 10.0.1)
- System.IO.Abstractions (>= 22.1.0)
- System.Threading.Channels (>= 10.0.1)
-
net10.0
- JetBrains.Annotations (>= 2025.2.4)
- Microsoft.Extensions.Logging.Configuration (>= 10.0.1)
- System.IO.Abstractions (>= 22.1.0)
-
net8.0
- JetBrains.Annotations (>= 2025.2.4)
- Microsoft.Extensions.Logging.Configuration (>= 10.0.1)
- System.IO.Abstractions (>= 22.1.0)
-
net9.0
- JetBrains.Annotations (>= 2025.2.4)
- Microsoft.Extensions.Logging.Configuration (>= 10.0.1)
- System.IO.Abstractions (>= 22.1.0)
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 |