Microsoft.Extensions.Logging.Console 9.0.2
About
Microsoft.Extensions.Logging.Console provides a Console logger provider implementation for Microsoft.Extensions.Logging. It provides extension methods for the ILoggingBuilder and ILoggerProviderConfiguration classes.
Key Features
- Allow logging to the console using the Microsoft.Extensions.Logging package.
- Provide extension methods for the ILoggingBuilder and ILoggerProviderConfiguration classes.
How to Use
using System;
using Microsoft.Extensions.Logging;
namespace ConsoleLoggerSample
{
class Program
{
static void Main(string[] args)
{
// Create a logger factory with a console provider
using ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
// Create a logger with the category name of the current class
ILogger<Program> logger = loggerFactory.CreateLogger<Program>();
// Log some messages with different log levels and message templates
logger.LogTrace("This is a trace message.");
logger.LogDebug("This is a debug message.");
logger.LogInformation("Hello {Name}!", "World");
logger.LogWarning("This is a warning message.");
logger.LogError("This is an error message.");
logger.LogCritical("This is a critical message.");
// Use structured logging to capture complex data
var person = new Person { Name = "Alice", Age = 25 };
logger.LogInformation("Created a new person: {@Person}", person);
// Use exception logging to capture the details of an exception
try
{
throw new Exception("Something went wrong.");
}
catch (Exception ex)
{
logger.LogError(ex, "An exception occurred.");
}
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
// A simple class to demonstrate structured logging
class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
}
Main Types
The main types provided by this library are:
ConsoleLoggerProviderConsoleLoggerSettingsConsoleLoggerOptionsConsoleLoggerExtensionsConsoleFormatterConsoleFormatterOptionsJsonConsoleFormatterOptionsSimpleConsoleFormatterOptions
Additional Documentation
Related Packages
Microsoft.Extensions.Logging.Abstractions Microsoft.Extensions.Logging Microsoft.Extensions.Logging.Debug Microsoft.Extensions.Logging.EventSource Microsoft.Extensions.Logging.EventLog Microsoft.Extensions.Logging.TraceSource
Feedback & Contributing
Microsoft.Extensions.Logging.Console is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
Showing the top 20 packages that depend on Microsoft.Extensions.Logging.Console.
| Packages | Downloads |
|---|---|
|
Microsoft.AspNetCore
Microsoft.AspNetCore
|
14 |
|
Microsoft.AspNetCore
Microsoft.AspNetCore
|
13 |
|
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
|
13 |
https://go.microsoft.com/fwlink/?LinkID=799421
.NET Framework 4.6.2
- Microsoft.Bcl.AsyncInterfaces (>= 9.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.2)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.2)
- Microsoft.Extensions.Logging (>= 9.0.2)
- System.Text.Json (>= 9.0.2)
- Microsoft.Extensions.Options (>= 9.0.2)
- System.Buffers (>= 4.5.1)
.NET Standard 2.0
- System.Buffers (>= 4.5.1)
- System.Text.Json (>= 9.0.2)
- Microsoft.Extensions.Options (>= 9.0.2)
- Microsoft.Extensions.Logging (>= 9.0.2)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.2)
- Microsoft.Bcl.AsyncInterfaces (>= 9.0.2)
.NET 9.0
- Microsoft.Extensions.Options (>= 9.0.2)
- Microsoft.Extensions.Logging (>= 9.0.2)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.2)
.NET 8.0
- Microsoft.Extensions.Options (>= 9.0.2)
- System.Text.Json (>= 9.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.2)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.2)
- Microsoft.Extensions.Logging (>= 9.0.2)
| Version | Downloads | Last updated |
|---|---|---|
| 9.0.2 | 13 | 02/18/2025 |
| 9.0.1 | 13 | 02/18/2025 |
| 9.0.0 | 12 | 02/18/2025 |
| 8.0.1 | 12 | 02/18/2025 |
| 8.0.0 | 12 | 01/22/2024 |
| 7.0.0 | 12 | 02/18/2025 |
| 7.0.0-preview.2.22152.2 | 13 | 02/18/2025 |
| 6.0.1 | 12 | 02/18/2025 |
| 6.0.0 | 13 | 06/15/2023 |
| 5.0.0 | 12 | 02/18/2025 |
| 3.1.32 | 11 | 02/18/2025 |
| 3.1.31 | 11 | 02/18/2025 |
| 3.1.30 | 11 | 02/18/2025 |
| 3.1.29 | 11 | 02/18/2025 |
| 3.1.28 | 11 | 02/18/2025 |
| 3.1.27 | 11 | 02/18/2025 |
| 3.1.26 | 14 | 02/18/2025 |
| 3.1.25 | 11 | 02/18/2025 |
| 3.1.24 | 11 | 02/18/2025 |
| 3.1.23 | 11 | 02/18/2025 |
| 3.1.22 | 11 | 02/18/2025 |
| 3.1.21 | 11 | 02/18/2025 |
| 3.1.20 | 11 | 02/18/2025 |
| 3.1.19 | 12 | 02/18/2025 |
| 3.1.18 | 12 | 02/18/2025 |
| 3.1.17 | 11 | 02/18/2025 |
| 3.1.16 | 11 | 02/18/2025 |
| 3.1.15 | 11 | 02/18/2025 |
| 3.1.14 | 11 | 02/18/2025 |
| 3.1.13 | 12 | 02/18/2025 |
| 3.1.12 | 11 | 02/18/2025 |
| 3.1.11 | 11 | 02/18/2025 |
| 3.1.10 | 11 | 02/18/2025 |
| 3.1.9 | 12 | 02/18/2025 |
| 3.1.8 | 12 | 02/18/2025 |
| 3.1.7 | 12 | 02/18/2025 |
| 3.1.6 | 13 | 02/18/2025 |
| 3.1.5 | 12 | 02/18/2025 |
| 3.1.4 | 13 | 02/18/2025 |
| 3.1.3 | 12 | 02/18/2025 |
| 3.1.2 | 12 | 02/18/2025 |
| 3.1.1 | 12 | 02/18/2025 |
| 3.1.0 | 13 | 02/18/2025 |
| 3.0.3 | 12 | 02/18/2025 |
| 3.0.2 | 12 | 02/18/2025 |
| 3.0.1 | 12 | 02/18/2025 |
| 3.0.0 | 12 | 02/18/2025 |
| 2.2.0 | 12 | 02/18/2025 |
| 2.1.1 | 12 | 02/18/2025 |
| 2.1.0 | 12 | 02/18/2025 |
| 2.1.0-rc1-final | 12 | 02/18/2025 |
| 2.1.0-preview2-final | 11 | 02/18/2025 |
| 2.1.0-preview1-final | 11 | 02/18/2025 |
| 2.0.2 | 12 | 02/18/2025 |
| 2.0.1 | 12 | 02/18/2025 |
| 2.0.0 | 12 | 02/18/2025 |
| 2.0.0-preview2-final | 11 | 02/18/2025 |
| 2.0.0-preview1-final | 11 | 02/18/2025 |
| 1.1.2 | 12 | 02/18/2025 |
| 1.1.1 | 11 | 02/18/2025 |
| 1.1.0 | 12 | 02/18/2025 |
| 1.1.0-preview1-final | 11 | 02/18/2025 |
| 1.0.2 | 12 | 02/18/2025 |
| 1.0.1 | 12 | 02/18/2025 |
| 1.0.0 | 12 | 02/18/2025 |
| 1.0.0-rc2-final | 11 | 02/18/2025 |
| 1.0.0-rc1-final | 11 | 02/18/2025 |