Microsoft.Extensions.Logging.Console 11.0.0-preview.2.26159.112

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
26
Microsoft.AspNetCore
Microsoft.AspNetCore
27
Microsoft.AspNetCore
Microsoft.AspNetCore
28
Microsoft.AspNetCore
Microsoft.AspNetCore
29
Microsoft.AspNetCore
Microsoft.AspNetCore
661
Microsoft.AspNetCore.All
Microsoft.AspNetCore.All
26
Microsoft.AspNetCore.All
Microsoft.AspNetCore.All
27
Microsoft.AspNetCore.All
Microsoft.AspNetCore.All
29
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
26
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
38
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
148
PDFsharp-MigraDoc-GDI
MigraDoc is a .NET library that allows developers to create documents such as PDF and RTF using a high-level object model. It provides an intuitive API that simplifies the creation of documents, including text formatting, tables, images, and more. MigraDoc is widely used for generating reports, invoices, and other types of documents in various applications. This package relies on Windows Forms (GDI+) and can be used under Windows only. See https://docs.pdfsharp.net for details.
28

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

.NET Framework 4.6.2

.NET Standard 2.0

.NET 11.0

.NET 10.0

Version Downloads Last updated
11.0.0-preview.2.26159.112 4 03/11/2026
11.0.0-preview.1.26104.118 6 02/12/2026
10.0.5 2 03/14/2026
10.0.4 3 03/11/2026
10.0.3 5 02/12/2026
10.0.2 6 01/15/2026
10.0.1 7 12/11/2025
10.0.0 11 11/13/2025
10.0.0-rc.2.25502.107 9 10/18/2025
10.0.0-rc.1.25451.107 11 09/11/2025
10.0.0-preview.7.25380.108 13 08/14/2025
10.0.0-preview.6.25358.103 14 07/17/2025
10.0.0-preview.5.25277.114 14 06/07/2025
10.0.0-preview.4.25258.110 14 05/16/2025
10.0.0-preview.3.25171.5 15 04/26/2025
10.0.0-preview.2.25163.2 18 03/20/2025
10.0.0-preview.1.25080.5 14 02/25/2025
9.0.14 4 03/11/2026
9.0.13 6 02/12/2026
9.0.12 7 01/15/2026
9.0.11 12 11/13/2025
9.0.10 10 10/18/2025
9.0.9 12 09/11/2025
9.0.8 12 08/07/2025
9.0.7 13 07/12/2025
9.0.6 15 06/14/2025
9.0.5 16 05/16/2025
9.0.4 13 04/26/2025
9.0.3 18 03/20/2025
9.0.2 15 02/19/2025
9.0.1 17 01/18/2025
9.0.0 15 03/05/2025
9.0.0-rc.2.24473.5 17 12/13/2024
9.0.0-rc.1.24431.7 18 01/06/2025
9.0.0-preview.7.24405.7 20 12/07/2024
9.0.0-preview.6.24327.7 18 01/06/2025
9.0.0-preview.5.24306.7 22 12/06/2024
9.0.0-preview.4.24266.19 16 12/29/2024
9.0.0-preview.3.24172.9 20 11/27/2024
9.0.0-preview.2.24128.5 19 04/01/2024
9.0.0-preview.1.24080.9 22 02/15/2024
8.0.1 24 12/15/2024
8.0.0 26 03/07/2024
8.0.0-rc.2.23479.6 18 03/07/2024
8.0.0-rc.1.23419.4 20 03/09/2024
8.0.0-preview.7.23375.6 17 03/09/2024
8.0.0-preview.6.23329.7 20 03/10/2024
8.0.0-preview.5.23280.8 22 03/10/2024
8.0.0-preview.4.23259.5 20 03/10/2024
8.0.0-preview.3.23174.8 24 11/06/2023
8.0.0-preview.2.23128.3 24 11/07/2023
8.0.0-preview.1.23110.8 21 11/14/2023
7.0.0 154 08/18/2023
7.0.0-rc.2.22472.3 22 03/07/2024
7.0.0-rc.1.22426.10 19 11/06/2023
7.0.0-preview.7.22375.6 24 03/09/2024
7.0.0-preview.6.22324.4 20 11/07/2023
7.0.0-preview.5.22301.12 14 03/10/2024
7.0.0-preview.4.22229.4 21 02/28/2024
7.0.0-preview.3.22175.4 20 03/08/2024
7.0.0-preview.2.22152.2 22 11/10/2023
7.0.0-preview.1.22076.8 17 11/11/2023
6.0.2-mauipre.1.22102.15 18 03/18/2024
6.0.2-mauipre.1.22054.8 17 11/12/2023
6.0.1 17 01/18/2025
6.0.0 32 08/18/2023
6.0.0-rc.2.21480.5 17 03/18/2024
6.0.0-rc.1.21451.13 19 03/09/2024
6.0.0-preview.7.21377.19 17 03/09/2024
6.0.0-preview.6.21352.12 19 03/09/2024
6.0.0-preview.5.21301.5 25 03/09/2024
6.0.0-preview.4.21253.7 23 03/09/2024
6.0.0-preview.3.21201.4 17 03/09/2024
6.0.0-preview.2.21154.6 19 03/15/2024
6.0.0-preview.1.21102.12 21 03/08/2024
5.0.0 19 03/07/2024
5.0.0-rc.2.20475.5 20 11/14/2023
5.0.0-rc.1.20451.14 20 03/18/2024
5.0.0-preview.8.20407.11 20 03/17/2024
5.0.0-preview.7.20364.11 16 03/18/2024
5.0.0-preview.6.20305.6 25 11/09/2023
5.0.0-preview.5.20278.1 23 01/18/2025
5.0.0-preview.4.20251.6 16 01/06/2025
5.0.0-preview.3.20215.2 23 11/10/2023
5.0.0-preview.2.20160.3 20 12/16/2024
5.0.0-preview.1.20120.4 20 03/07/2024
3.1.32 22 02/26/2024
3.1.31 27 03/16/2024
3.1.30 20 03/17/2024
3.1.29 20 03/26/2024
3.1.28 28 03/07/2024
3.1.27 20 03/17/2024
3.1.26 20 03/15/2024
3.1.25 22 03/08/2024
3.1.24 22 03/18/2024
3.1.23 19 03/16/2024
3.1.22 31 03/19/2024
3.1.21 21 03/07/2024
3.1.20 19 03/08/2024
3.1.19 23 03/15/2024
3.1.18 21 03/15/2024
3.1.17 24 11/14/2023
3.1.16 23 03/19/2024
3.1.15 20 11/08/2023
3.1.14 19 03/15/2024
3.1.13 23 03/08/2024
3.1.12 25 03/15/2024
3.1.11 19 03/15/2024
3.1.10 19 03/08/2024
3.1.9 19 03/07/2024
3.1.8 18 03/17/2024
3.1.7 20 11/08/2023
3.1.6 23 11/11/2023
3.1.5 18 11/07/2023
3.1.4 25 01/08/2024
3.1.3 23 03/01/2024
3.1.2 25 03/07/2024
3.1.1 21 11/08/2023
3.1.0 23 11/12/2023
3.1.0-preview3.19553.2 22 03/09/2024
3.1.0-preview2.19525.4 21 03/11/2024
3.1.0-preview1.19506.1 25 11/13/2023
3.0.3 19 03/15/2024
3.0.2 20 03/15/2024
3.0.1 19 03/07/2024
3.0.0 21 03/07/2024
3.0.0-rc1.19456.10 19 03/17/2024
3.0.0-preview9.19423.4 27 03/10/2024
3.0.0-preview8.19405.4 21 03/09/2024
3.0.0-preview7.19362.4 18 01/06/2025
3.0.0-preview6.19304.6 21 11/11/2023
3.0.0-preview5.19227.9 21 03/15/2024
3.0.0-preview4.19216.2 20 03/15/2024
3.0.0-preview3.19153.1 21 01/16/2025
3.0.0-preview.19074.2 22 03/11/2024
3.0.0-preview.18572.1 24 03/09/2024
2.2.0 709 08/18/2023
2.2.0-preview3-35497 26 03/10/2024
2.2.0-preview2-35157 24 03/09/2024
2.2.0-preview1-35029 23 03/16/2024
2.1.1 21 03/15/2024
2.1.0 24 03/07/2024
2.1.0-rc1-final 19 11/12/2023
2.1.0-preview2-final 21 03/15/2024
2.1.0-preview1-final 26 03/16/2024
2.0.2 20 03/07/2024
2.0.1 25 11/11/2023
2.0.0 17 03/24/2024
2.0.0-preview2-final 28 11/13/2023
2.0.0-preview1-final 21 11/11/2023
1.1.2 17 03/15/2024
1.1.1 16 01/18/2025
1.1.0 18 03/06/2024
1.1.0-preview1-final 21 11/11/2023
1.0.2 18 11/07/2023
1.0.1 22 03/15/2024
1.0.0 20 03/07/2024
1.0.0-rc2-final 19 03/16/2024
1.0.0-rc1-final 19 03/28/2024