Microsoft.Extensions.Logging.Console 9.0.0-preview.1.24080.9
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.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.
|
49 |
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.
|
46 |
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
|
43 |
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
|
40 |
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.
|
36 |
Microsoft.AspNetCore.App
Microsoft.AspNetCore.App
|
35 |
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
This package was built from the source at:
https://github.com/aspnet/javascriptservices/tree/3265b92086cb62a98d7a486f9e8f81a77ef56afc
|
34 |
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
|
34 |
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
|
32 |
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.
|
32 |
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
When using NuGet 3.x this package requires at least version 3.4.
|
32 |
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/a4938d07a5127ffad8466ddf703a6b5b21f4b0c9
|
31 |
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.
This package was built from the source at:
https://github.com/aspnet/Universe/tree/244e037a222a7cd0a17feafb7f3a625fde40de97
|
30 |
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
This package was built from the source code at https://github.com/aspnet/AspNetCore/tree/bd1e14b7d16b798de8a874189c89afed755a266c
|
26 |
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
|
25 |
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
|
24 |
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.
|
24 |
https://go.microsoft.com/fwlink/?LinkID=799421
.NET Framework 4.6.2
- Microsoft.Bcl.AsyncInterfaces (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Logging (>= 9.0.0-preview.1.24080.9)
- System.Text.Json (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Options (>= 9.0.0-preview.1.24080.9)
- System.Buffers (>= 4.5.1)
.NET Standard 2.0
- System.Buffers (>= 4.5.1)
- System.Text.Json (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Options (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Logging (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0-preview.1.24080.9)
- Microsoft.Bcl.AsyncInterfaces (>= 9.0.0-preview.1.24080.9)
.NET 9.0
- System.Text.Json (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Options (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Logging (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0-preview.1.24080.9)
.NET 8.0
- Microsoft.Extensions.Options (>= 9.0.0-preview.1.24080.9)
- System.Text.Json (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0-preview.1.24080.9)
- Microsoft.Extensions.Logging (>= 9.0.0-preview.1.24080.9)