CodeFoxtrot.ConsoleLogger
1.0.7
dotnet add package CodeFoxtrot.ConsoleLogger --version 1.0.7
NuGet\Install-Package CodeFoxtrot.ConsoleLogger -Version 1.0.7
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.ConsoleLogger" Version="1.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CodeFoxtrot.ConsoleLogger" Version="1.0.7" />
<PackageReference Include="CodeFoxtrot.ConsoleLogger" />
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 CodeFoxtrot.ConsoleLogger --version 1.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CodeFoxtrot.ConsoleLogger, 1.0.7"
#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 CodeFoxtrot.ConsoleLogger@1.0.7
#: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=CodeFoxtrot.ConsoleLogger&version=1.0.7
#tool nuget:?package=CodeFoxtrot.ConsoleLogger&version=1.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ConsoleLogger - Simple is Good
- Cross-platform implementation supporting asynchronous Console logging.
- Configurable default minimum log level.
- Single-line, Multi-line or Custom log entry formats.
- Indent multiline messages for easier reading and analysis.
- Configurable color scheme for Console log messages, for easier reading.

Single-line Format

Multi-line Format

How to use
Scenario #1: Quickstart
using ConsoleLoggerLibrary;
...<omitted>...
.ConfigureLogging((context, builder) =>
{
builder.ClearProviders();
builder.AddConsoleLogger();
})
Scenario #2: Using appsettings.json
appsettings.json -- all options shown
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Error"
},
"ConsoleLogger": {
"LogMinLevel": "Debug",
"UseUtcTimestamp": false,
"MultilineFormat": false,
"IndentMultilineMessages": true,
"EnableConsoleColors": true,
"LogLevelColors": {
"Trace": "Cyan",
"Debug": "Blue",
"Information": "Green",
"Warning": "Yellow",
"Error": "Red",
"Critical": "Magenta",
"None": "White"
}
}
}
}
Program.cs -- full file for complete context
using ConsoleLoggerLibrary;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace ConsoleLoggerDemo;
internal class Program
{
static async Task Main(string[] args)
{
try
{
await Host.CreateDefaultBuilder(args)
.ConfigureLogging((context, builder) =>
{
builder.ClearProviders();
builder.AddConsoleLogger(context.Configuration);
})
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<App>();
})
.RunConsoleAsync();
}
catch (Exception ex)
{
Console.WriteLine($"Unexpected error: {ex.Message}");
}
}
}
Scenario #3: Using ConfigureLogging
Program.cs -- full file for complete context, all ConsoleLoggerOptions shown
using ConsoleLoggerLibrary;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace ConsoleLoggerDemo;
internal class Program
{
static async Task Main(string[] args)
{
try
{
await Host.CreateDefaultBuilder(args)
.ConfigureLogging((context, builder) =>
{
builder.ClearProviders();
builder.AddConsoleLogger(configure =>
{
configure.LogMinLevel = LogLevel.Trace;
configure.UseUtcTimestamp = false;
configure.MultiLineFormat = false;
configure.IndentMultilineMessages = 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
};
});
})
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<App>();
})
.RunConsoleAsync();
}
catch (Exception ex)
{
Console.WriteLine($"Unexpected error: {ex.Message}");
}
}
}
Indentation
IndentMultilineMessages=true
2022-04-04--18.10.20|INFO|ConsoleLoggerDemo.App|{
"Date": "6/24/2022",
"Location": "Center Moriches",
"TemperatureCelsius": 20,
"Summary": "Nice"
}
IndentMultilineMessages=false
2022-04-04--18.11.19|INFO|ConsoleLoggerDemo.App|{
"Date": "6/24/2022",
"Location": "Center Moriches",
"TemperatureCelsius": 20,
"Summary": "Nice"
}
Note: The IndentMultilineMessages option is only for the Single-Line message format.
Roadmap
- No current plans
Reference
https://docs.microsoft.com/en-us/dotnet/core/extensions/custom-logging-provider
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.2)
- Microsoft.Extensions.Logging (>= 10.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.2)
-
net8.0
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
-
net9.0
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.12)
- Microsoft.Extensions.Logging (>= 9.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.