Microsoft.Extensions.Logging.Console 9.0.0
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.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
|
59 |
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/1aa50faa290ecda304507981cd01ed92651d5e34
|
55 |
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/b908e913e3befcfe241f3294509e6d9570acc07b
|
55 |
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/f6897a5bb7ca767df8eb465bf15b193c878fffbf
|
55 |
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
|
55 |
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/80fec4e3edea3972e95885f5c0db6ee06072f917
|
52 |
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
|
52 |
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/67e04394e98d5bfa6a5684d471a72fcbe30fd587
|
52 |
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
|
51 |
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/c04846dc66cc97f71d83a83a15437828435f5d44
|
51 |
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
|
50 |
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
|
50 |
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/561deb05ae2d6680206e3d4a6bc75de699585980
|
49 |
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/aee5e4080331553ea9dfb7fb388b6d72f715bf6a
|
49 |
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
|
49 |
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/0a2e366eaf4d29b24b9a98e5782a04bef573189e
|
49 |
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
|
48 |
.NET Framework 4.6.2
- Microsoft.Bcl.AsyncInterfaces (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
- System.Text.Json (>= 9.0.0)
- System.Buffers (>= 4.5.1)
.NET 8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
- System.Text.Json (>= 9.0.0)
.NET 9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
.NET Standard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
- System.Text.Json (>= 9.0.0)
- System.Buffers (>= 4.5.1)