ConsoleMonster.Extensions.Logging
2.1.2
dotnet add package ConsoleMonster.Extensions.Logging --version 2.1.2
NuGet\Install-Package ConsoleMonster.Extensions.Logging -Version 2.1.2
<PackageReference Include="ConsoleMonster.Extensions.Logging" Version="2.1.2" />
<PackageVersion Include="ConsoleMonster.Extensions.Logging" Version="2.1.2" />
<PackageReference Include="ConsoleMonster.Extensions.Logging" />
paket add ConsoleMonster.Extensions.Logging --version 2.1.2
#r "nuget: ConsoleMonster.Extensions.Logging, 2.1.2"
#:package ConsoleMonster.Extensions.Logging@2.1.2
#addin nuget:?package=ConsoleMonster.Extensions.Logging&version=2.1.2
#tool nuget:?package=ConsoleMonster.Extensions.Logging&version=2.1.2
ConsoleMonster.Extensions.Logging
A Microsoft.Extensions.Logging provider that writes log entries the ConsoleMonster way. It depends only on
Microsoft.Extensions.Logging.Abstractions and ConsoleMonster.
dotnet add package ConsoleMonster.Extensions.Logging
using ConsoleMonster.Extensions.Logging;
using Microsoft.Extensions.Logging;
using ILoggerFactory factory = LoggerFactory.Create(logging => logging.AddConsoleMonster());
ILogger log = factory.CreateLogger("Shop.Orders");
using (log.BeginScope("order {Id}", 1042)) {
log.LogInformation("Payment accepted");
log.LogWarning("Stock is low for {Sku}", "A-17");
}
14:05:12 Orders (order 1042) Payment accepted
14:05:12 ▴ WARN Orders (order 1042) Stock is low for A-17
What it does
- Each entry gets the level tag and colour that
Write-ConsoleLogEntryand the dashboard log region use:✗ ERRfor Error and Critical;▴ WARNfor Warning;DBGandVERBfor Debug and Trace, with the text muted;- no tag for Information.
- A timestamp comes first (
TimestampFormat, defaultHH:mm:ss; null leaves it out;UseUtcTimestamp). - Then the category: the last part by default,
Full, orNone. Scopes follow in brackets (IncludeScopes). - The event id is shown only when asked for (
IncludeEventId). - An exception's type and message print under the entry, with up to
MaxExceptionLineslines of details. While a dashboard shows, such entries print above it rather than into its log, so the details stay in the scrollback. - While a live session with a log region runs, such as a ConsoleMonster dashboard or
ConsoleMonster.Hosting'sAddConsoleDashboard, entries go into that region (LogRegion, default$log), so they never print over the view. - With output redirected (CI, a file, a pipe), entries are plain lines without escape codes. Colours and glyphs follow the terminal, as everywhere in ConsoleMonster.
Options
| Option | Default | Meaning |
|---|---|---|
MinimumLevel |
Trace |
The lowest level written; the logging builder's filters apply first. |
TimestampFormat |
HH:mm:ss |
A .NET date format, or null for no timestamp. |
UseUtcTimestamp |
false |
UTC instead of local time. |
Category |
Short |
Short, Full or None. |
IncludeScopes |
true |
Shows the scopes after the category. |
IncludeEventId |
false |
Shows the event id. |
MaxExceptionLines |
12 |
Lines of exception details; 0 for the type and message only. |
LogRegion |
$log |
The live log region to write into while one runs; null always prints. |
Profile, Writer |
current terminal | Where and for which terminal lines are written (tests, files). |
The provider is added once: a second AddConsoleMonster keeps the first call's options. Without dependency
injection, use loggerFactory.AddConsoleMonster(). The provider is thread-safe and works with
trimming and native AOT on .NET 8 and later.
| 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 was computed. 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 is compatible. 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. |
-
.NETFramework 4.7.2
- ConsoleMonster (>= 2.1.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
-
.NETStandard 2.0
- ConsoleMonster (>= 2.1.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
-
net10.0
- ConsoleMonster (>= 2.1.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
-
net8.0
- ConsoleMonster (>= 2.1.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Changes in each release: https://github.com/EvotecIT/ConsoleMonster/blob/master/CHANGELOG.MD