Microsoft.Extensions.Logging.Debug 9.0.0
About
Microsoft.Extensions.Logging.Debug provides a Debug output logger provider implementation for Microsoft.Extensions.Logging. This logger logs messages to a debugger monitor by writing messages with System.Diagnostics.Debug.WriteLine().
Key Features
- Allow logging to the debugger output.
- Provide extensions method for the ILoggingBuilder class to easily enable this Debug logger.
How to Use
using System;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Debug;
namespace DebugLoggerSample
{
class Program
{
static void Main(string[] args)
{
// Create a logger factory with a debug provider
using ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddDebug());
// 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:
DebugLoggerProviderDebugLoggerFactoryExtensions
Additional Documentation
Related Packages
Microsoft.Extensions.Logging.Abstractions Microsoft.Extensions.Logging Microsoft.Extensions.Logging.Console Microsoft.Extensions.Logging.EventSource Microsoft.Extensions.Logging.EventLog Microsoft.Extensions.Logging.TraceSource
Feedback & Contributing
Microsoft.Extensions.Logging.Debug 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.Debug.
| Packages | Downloads |
|---|---|
|
Microsoft.AspNetCore
Microsoft.AspNetCore
|
15 |
|
Microsoft.AspNetCore.Hosting
ASP.NET Core hosting infrastructure and startup logic for web applications.
|
15 |
|
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
|
14 |
|
Microsoft.AspNetCore
Microsoft.AspNetCore
|
14 |
|
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
|
13 |
|
Microsoft.AspNetCore
Microsoft.AspNetCore
|
13 |
https://go.microsoft.com/fwlink/?LinkID=799421
.NET Framework 4.6.2
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
.NET Standard 2.0
- Microsoft.Extensions.Logging (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
.NET 9.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
.NET 8.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
| Version | Downloads | Last updated |
|---|---|---|
| 9.0.2 | 15 | 02/18/2025 |
| 9.0.1 | 13 | 02/18/2025 |
| 9.0.0 | 13 | 02/18/2025 |
| 8.0.1 | 12 | 02/18/2025 |
| 8.0.0 | 14 | 01/22/2024 |
| 7.0.0 | 14 | 02/18/2025 |
| 6.0.1 | 15 | 02/18/2025 |
| 6.0.0 | 18 | 06/15/2023 |
| 5.0.0 | 15 | 02/18/2025 |
| 5.0.0-preview.5.20278.1 | 15 | 02/18/2025 |
| 3.1.32 | 15 | 02/18/2025 |
| 3.1.31 | 15 | 02/18/2025 |
| 3.1.30 | 15 | 02/18/2025 |
| 3.1.29 | 15 | 02/18/2025 |
| 3.1.28 | 15 | 02/18/2025 |
| 3.1.27 | 16 | 02/18/2025 |
| 3.1.26 | 15 | 02/18/2025 |
| 3.1.25 | 15 | 02/18/2025 |
| 3.1.24 | 16 | 02/18/2025 |
| 3.1.23 | 16 | 02/18/2025 |
| 3.1.22 | 15 | 02/18/2025 |
| 3.1.21 | 15 | 02/18/2025 |
| 3.1.20 | 15 | 02/18/2025 |
| 3.1.19 | 15 | 02/18/2025 |
| 3.1.18 | 16 | 02/18/2025 |
| 3.1.17 | 15 | 02/18/2025 |
| 3.1.16 | 15 | 02/18/2025 |
| 3.1.15 | 15 | 02/18/2025 |
| 3.1.14 | 16 | 02/18/2025 |
| 3.1.13 | 15 | 02/18/2025 |
| 3.1.12 | 16 | 02/18/2025 |
| 3.1.11 | 16 | 02/18/2025 |
| 3.1.10 | 16 | 02/18/2025 |
| 3.1.9 | 16 | 02/18/2025 |
| 3.1.8 | 16 | 02/18/2025 |
| 3.1.7 | 16 | 02/18/2025 |
| 3.1.6 | 15 | 02/18/2025 |
| 3.1.5 | 16 | 02/18/2025 |
| 3.1.4 | 16 | 02/18/2025 |
| 3.1.3 | 16 | 02/18/2025 |
| 3.1.2 | 16 | 02/18/2025 |
| 3.1.1 | 16 | 02/18/2025 |
| 3.1.0 | 15 | 02/18/2025 |
| 3.0.3 | 15 | 02/18/2025 |
| 3.0.2 | 15 | 02/18/2025 |
| 3.0.1 | 15 | 02/18/2025 |
| 3.0.0 | 15 | 02/18/2025 |
| 2.2.0 | 16 | 02/18/2025 |
| 2.1.1 | 15 | 02/18/2025 |
| 2.1.0 | 16 | 02/18/2025 |
| 2.1.0-rc1-final | 15 | 02/18/2025 |
| 2.1.0-preview2-final | 16 | 02/18/2025 |
| 2.1.0-preview1-final | 14 | 02/18/2025 |
| 2.0.2 | 16 | 02/18/2025 |
| 2.0.1 | 13 | 02/18/2025 |
| 2.0.0 | 12 | 02/18/2025 |
| 2.0.0-preview2-final | 14 | 02/18/2025 |
| 2.0.0-preview1-final | 13 | 02/18/2025 |
| 1.1.2 | 14 | 02/18/2025 |
| 1.1.1 | 13 | 02/18/2025 |
| 1.1.0 | 13 | 02/18/2025 |
| 1.1.0-preview1-final | 13 | 02/18/2025 |
| 1.0.2 | 14 | 02/18/2025 |
| 1.0.1 | 14 | 02/18/2025 |
| 1.0.0 | 13 | 02/18/2025 |
| 1.0.0-rc2-final | 13 | 02/18/2025 |
| 1.0.0-rc1-final | 13 | 02/18/2025 |