Microsoft.Extensions.Logging.Console 9.0.6

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
30
Microsoft.AspNetCore
Microsoft.AspNetCore
31
Microsoft.AspNetCore
Microsoft.AspNetCore
32
Microsoft.AspNetCore
Microsoft.AspNetCore
36
Microsoft.AspNetCore
Microsoft.AspNetCore
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/2b7e994b8a304700a09617ffc5052f0d943bbcba
255
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
37
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/7b22a279ec975335bbb0a7cbadef2e45ee15aa9c
74
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/9699b939f94b7524a178821d78addefa5af5d750
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/d12868dd7c10ff0433c16b06d3b59d03c40d987a
30
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
34
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
35
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
38
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
59
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
30
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
55
Pomelo.EntityFrameworkCore.MySql
Package Description
33
Pomelo.EntityFrameworkCore.MySql
Package Description
34

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

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