Microsoft.Extensions.Logging.Console 10.0.0-preview.4.25258.110

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

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

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
23
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
23
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/509f6badec2f3162f0e50330cd9107e5624b379b
38
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/535da07711bd5e2d8e44c0ea10bd2c8be1a9a584
24
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
22
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/c3acdcac86dad91c3d3fbc3b93ecc6b7ba494bdc
25
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
25
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
29
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
179
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
28
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
5,342
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
8,850
nacos-sdk-csharp.Extensions.Configuration
nacos csharp sdk
49
PDFsharp
PDFsharp is the Open Source library for creating and modifying PDF documents using .NET. It has an easy-to-use API that allows developers to generate or modify PDF files programmatically. PDFsharp can be used for various applications, including creating reports, invoices, and other types of documents. This package does not depend on Windows and can be used on any .NET compatible platform including Linux and macOS. See https://docs.pdfsharp.net for details.
23
PDFsharp
PDFsharp is the Open Source library for creating and modifying PDF documents using .NET. It has an easy-to-use API that allows developers to generate or modify PDF files programmatically. PDFsharp can be used for various applications, including creating reports, invoices, and other types of documents. This package does not depend on Windows and can be used on any .NET compatible platform including Linux and macOS. See https://docs.pdfsharp.net for details.
24
PDFsharp
PDFsharp is the Open Source library for creating and modifying PDF documents using .NET. It has an easy-to-use API that allows developers to generate or modify PDF files programmatically. PDFsharp can be used for various applications, including creating reports, invoices, and other types of documents. This package does not depend on Windows and can be used on any .NET compatible platform including Linux and macOS. See https://docs.pdfsharp.net for details.
25
Pomelo.EntityFrameworkCore.MySql
Package Description
29
Pomelo.EntityFrameworkCore.MySql.Design
Package Description
24
Quantum.FrameworkNetCore
Used for set up Micro-Service.
22

https://go.microsoft.com/fwlink/?LinkID=799421

.NET Framework 4.6.2

.NET Standard 2.0

.NET 10.0

.NET 9.0

.NET 8.0

Version Downloads Last updated
10.0.0-preview.4.25258.110 2 05/15/2025
10.0.0-preview.3.25171.5 4 04/26/2025
10.0.0-preview.2.25163.2 4 03/30/2025
10.0.0-preview.1.25080.5 6 03/12/2025
9.0.5 3 05/16/2025
9.0.4 3 04/27/2025
9.0.3 5 03/12/2025
9.0.2 7 03/12/2025
9.0.1 9 01/28/2025
9.0.0 21 11/15/2024
9.0.0-rc.2.24473.5 12 11/14/2024
9.0.0-rc.1.24431.7 10 11/28/2024
9.0.0-preview.7.24405.7 10 11/14/2024
9.0.0-preview.6.24327.7 10 11/14/2024
9.0.0-preview.5.24306.7 12 11/12/2024
9.0.0-preview.4.24266.19 17 05/21/2024
9.0.0-preview.3.24172.9 14 05/05/2024
9.0.0-preview.2.24128.5 14 04/28/2024
9.0.0-preview.1.24080.9 17 05/02/2024
8.0.1 17 11/12/2024
8.0.0 176 02/04/2024
8.0.0-rc.2.23479.6 15 05/29/2024
8.0.0-rc.1.23419.4 15 04/30/2024
8.0.0-preview.7.23375.6 19 05/29/2024
8.0.0-preview.6.23329.7 27 08/07/2023
8.0.0-preview.5.23280.8 13 05/15/2024
8.0.0-preview.4.23259.5 14 05/21/2024
8.0.0-preview.3.23174.8 17 05/02/2024
8.0.0-preview.2.23128.3 15 05/02/2024
8.0.0-preview.1.23110.8 18 05/02/2024
7.0.0 36 02/02/2023
7.0.0-rc.2.22472.3 14 05/14/2024
7.0.0-rc.1.22426.10 18 05/04/2024
7.0.0-preview.7.22375.6 11 05/29/2024
7.0.0-preview.6.22324.4 19 04/24/2024
7.0.0-preview.5.22301.12 11 11/28/2024
7.0.0-preview.4.22229.4 17 05/29/2024
7.0.0-preview.3.22175.4 13 05/29/2024
7.0.0-preview.2.22152.2 17 05/29/2024
7.0.0-preview.1.22076.8 11 05/29/2024
6.0.2-mauipre.1.22102.15 12 05/11/2024
6.0.2-mauipre.1.22054.8 10 05/29/2024
6.0.1 16 11/28/2024
6.0.0 49 07/01/2022
6.0.0-rc.2.21480.5 20 05/25/2024
6.0.0-rc.1.21451.13 12 02/09/2023
6.0.0-preview.7.21377.19 11 05/29/2024
6.0.0-preview.6.21352.12 14 05/04/2024
6.0.0-preview.5.21301.5 16 05/19/2024
6.0.0-preview.4.21253.7 14 05/29/2024
6.0.0-preview.3.21201.4 13 05/29/2024
6.0.0-preview.2.21154.6 15 04/30/2024
6.0.0-preview.1.21102.12 11 05/29/2024
5.0.0-rc.2.20475.5 14 05/11/2024
5.0.0-rc.1.20451.14 17 05/20/2024
5.0.0-preview.8.20407.11 13 05/29/2024
5.0.0-preview.7.20364.11 13 05/29/2024
5.0.0-preview.6.20305.6 17 05/01/2024
5.0.0-preview.5.20278.1 16 05/23/2024
5.0.0-preview.4.20251.6 13 05/02/2024
5.0.0-preview.3.20215.2 11 05/25/2024
5.0.0-preview.1.20120.4 17 05/02/2024
3.1.32 8,906 05/12/2023
3.1.31 18 05/17/2024
3.1.30 5,392 11/03/2022
3.1.29 14 05/19/2024
3.1.28 18 05/10/2024
3.1.27 16 05/26/2024
3.1.26 14 05/23/2024
3.1.25 16 05/11/2024
3.1.14 15 05/25/2024
3.1.13 21 02/24/2023
3.1.11 27 05/29/2024
3.1.3 19 05/09/2024
3.1.1 19 05/29/2024
3.1.0-preview3.19553.2 13 11/04/2022
3.1.0-preview2.19525.4 16 05/29/2024
3.1.0-preview1.19506.1 18 05/02/2024
3.0.1 14 05/29/2024
3.0.0-rc1.19456.10 16 05/29/2024
3.0.0-preview5.19227.9 12 05/02/2024
3.0.0-preview3.19153.1 13 05/18/2024
3.0.0-preview.18572.1 12 05/29/2024
2.2.0 19 08/17/2023
2.2.0-preview3-35497 17 05/07/2024
2.2.0-preview2-35157 10 05/25/2024
2.1.0-rc1-final 19 05/13/2024
2.0.0 16 05/11/2024
1.1.2 16 05/06/2024
1.1.0 19 05/29/2024
1.1.0-preview1-final 16 05/14/2024
1.0.0 16 05/02/2024
1.0.0-rc2-final 15 05/02/2024
1.0.0-rc1-final 15 05/02/2024