CodeFoxtrot.FileLogger
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package CodeFoxtrot.FileLogger --version 1.0.0
NuGet\Install-Package CodeFoxtrot.FileLogger -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="CodeFoxtrot.FileLogger" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CodeFoxtrot.FileLogger --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CodeFoxtrot.FileLogger, 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 CodeFoxtrot.FileLogger as a Cake Addin #addin nuget:?package=CodeFoxtrot.FileLogger&version=1.0.0 // Install CodeFoxtrot.FileLogger as a Cake Tool #tool nuget:?package=CodeFoxtrot.FileLogger&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FileLogger - Simple is Good
- Simple implementation supporting asynchronous Console and File logging.
- Rolling logs with configurable maximum size, maximum count and append of existing log.
- Configurable minimum log level.
- Indent multiline messages for easier reading and analysis.
- Configurable color scheme for Console log messages, for easier reading.
Configuration
Example appsettings.json configuration:
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Error"
},
"FileLogger": {
"LogName": "FileLoggerDemo",
"LogFolder": "",
"LogMaxBytes": 52428800,
"LogMaxCount": 10,
"LogMinLevel": "Trace",
"IndentMultilineMessages": true,
"ConsoleLogging": true,
"EnableConsoleColors": true,
"LogLevelColors": {
"Trace": "Cyan",
"Debug": "Blue",
"Information": "Green",
"Warning": "Yellow",
"Error": "Red",
"Critical": "Magenta",
"None": "White"
}
}
}
}
Example IHostBuilder implementation:
logging.AddFileLogger(configure =>
{
configure.LogName = "FileLoggerDemo";
configure.LogFolder = $@"{Environment.CurrentDirectory}\log";
configure.LogMaxBytes = 50 * 1048576;
configure.LogMaxCount = 10;
configure.LogMinLevel = LogLevel.Trace;
configure.IndentMultilineMessages = true;
configure.ConsoleLogging = true;
configure.EnableConsoleColors = true;
configure.LogLevelColors = new Dictionary<LogLevel, ConsoleColor>()
{
[LogLevel.Trace] = ConsoleColor.Cyan,
[LogLevel.Debug] = ConsoleColor.Blue,
[LogLevel.Information] = ConsoleColor.Green,
[LogLevel.Warning] = ConsoleColor.Yellow,
[LogLevel.Error] = ConsoleColor.Red,
[LogLevel.Critical] = ConsoleColor.DarkRed,
[LogLevel.None] = ConsoleColor.White
};
});
Indentation
IndentMultilineMessages=true
2022-04-04--18.10.20|INFO|FileLoggerDemo.App|{
"Date": "4/4/2022",
"Location": "Center Moriches",
"TemperatureCelsius": 20,
"Summary": "Nice"
}
IndentMultilineMessages=false
2022-04-04--18.11.19|INFO|FileLoggerDemo.App|{
"Date": "4/4/2022",
"Location": "Center Moriches",
"TemperatureCelsius": 20,
"Summary": "Nice"
}
Roadmap
- Support for Daily, Weekly or Monthly rolling log, up to 1GB maximum single log file.
Reference
https://docs.microsoft.com/en-us/dotnet/core/extensions/custom-logging-provider
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0-windows7.0
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CodeFoxtrot.FileLogger:
Package | Downloads |
---|---|
CodeFoxtrot.WindowsHelpers
Useful set of helper methods for C# in the Microsoft Windows environment. |
GitHub repositories
This package is not used by any popular GitHub repositories.