Microsoft.Extensions.Logging.Console 10.0.0-preview.2.25163.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:
ConsoleLoggerProvider
ConsoleLoggerSettings
ConsoleLoggerOptions
ConsoleLoggerExtensions
ConsoleFormatter
ConsoleFormatterOptions
JsonConsoleFormatterOptions
SimpleConsoleFormatterOptions
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.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core.
This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
|
5 |
Pomelo.EntityFrameworkCore.MySql
Package Description
|
4 |
Microsoft.AspNetCore.App
Microsoft.AspNetCore.App
|
4 |
Microsoft.Orleans.CounterControl
Tool that registers performance counter categories for performance counters published by Orleans runtime.
|
4 |
Microsoft.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application.
This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
|
4 |
Microsoft.Orleans.Reminders.AzureStorage
Microsoft Orleans reminders provider backed by Azure Table Storage
|
4 |
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core.
This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
|
4 |
Pomelo.EntityFrameworkCore.MySql.Design
Package Description
|
4 |
Microsoft.AspNetCore
Microsoft.AspNetCore
|
4 |
Microsoft.Orleans.Streaming
Streaming library for Microsoft Orleans used both on the client and server.
|
4 |
Microsoft.Orleans.CounterControl
Tool that registers performance counter categories for performance counters published by Orleans runtime.
|
3 |
Microsoft.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application.
This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
|
3 |
Pomelo.EntityFrameworkCore.MySql
MySQL provider for Entity Framework Core
|
3 |
Pomelo.EntityFrameworkCore.MySql
Package Description
|
3 |
Microsoft.Orleans.Persistence.AzureStorage
Microsoft Orleans persistence providers backed by Azure Storage
|
3 |
https://go.microsoft.com/fwlink/?LinkID=799421
.NET Framework 4.6.2
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Logging.Configuration (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Logging (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Options (>= 10.0.0-preview.2.25163.2)
- System.Buffers (>= 4.6.0)
- System.Text.Json (>= 10.0.0-preview.2.25163.2)
.NET Standard 2.0
- System.Buffers (>= 4.6.0)
- System.Text.Json (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Options (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Logging (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Logging.Configuration (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0-preview.2.25163.2)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.0-preview.2.25163.2)
.NET 10.0
- Microsoft.Extensions.Options (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Logging (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Logging.Configuration (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0-preview.2.25163.2)
.NET 9.0
- Microsoft.Extensions.Options (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Logging (>= 10.0.0-preview.2.25163.2)
- System.Text.Json (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Logging.Configuration (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0-preview.2.25163.2)
.NET 8.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Logging.Configuration (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Logging (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Options (>= 10.0.0-preview.2.25163.2)
- System.Text.Json (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0-preview.2.25163.2)