Microsoft.Extensions.Logging.Console 10.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

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.Extensions.Hosting
Hosting and startup infrastructures for applications.
2,908
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
2,818
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
88
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
85
Microsoft.AspNetCore
Microsoft.AspNetCore
82
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
78
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
77
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications. When using NuGet 3.x this package requires at least version 3.4.
77
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
75
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
75
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
74
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
73
Microsoft.AspNetCore
Microsoft.AspNetCore
71
Microsoft.AspNetCore
Microsoft.AspNetCore
70
Microsoft.AspNetCore
Microsoft.AspNetCore
69
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
69
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
69

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 6 11/12/2025
10.0.0-rc.2.25502.107 7 10/16/2025
10.0.0-rc.1.25451.107 14 09/11/2025
10.0.0-preview.7.25380.108 14 08/14/2025
10.0.0-preview.6.25358.103 14 07/16/2025
10.0.0-preview.5.25277.114 16 06/14/2025
10.0.0-preview.4.25258.110 22 05/17/2025
10.0.0-preview.3.25171.5 23 04/12/2025
10.0.0-preview.2.25163.2 34 03/20/2025
10.0.0-preview.1.25080.5 29 03/01/2025
9.0.11 4 11/13/2025
9.0.10 5 10/16/2025
9.0.9 12 09/11/2025
9.0.8 11 08/07/2025
9.0.7 15 07/10/2025
9.0.6 23 06/12/2025
9.0.5 22 05/17/2025
9.0.4 24 04/10/2025
9.0.3 28 03/14/2025
9.0.2 27 02/15/2025
9.0.1 33 01/20/2025
9.0.0 41 11/17/2024
9.0.0-rc.2.24473.5 39 10/15/2024
9.0.0-rc.1.24431.7 42 09/12/2024
9.0.0-preview.7.24405.7 47 08/14/2024
9.0.0-preview.6.24327.7 47 07/11/2024
9.0.0-preview.5.24306.7 55 06/15/2024
9.0.0-preview.4.24266.19 41 05/23/2024
9.0.0-preview.3.24172.9 46 04/13/2024
9.0.0-preview.2.24128.5 56 03/14/2024
9.0.0-preview.1.24080.9 48 03/08/2024
8.0.1 54 10/09/2024
8.0.0 2,922 11/14/2023
8.0.0-rc.2.23479.6 59 10/24/2023
8.0.0-rc.1.23419.4 44 09/16/2023
8.0.0-preview.7.23375.6 44 09/03/2023
8.0.0-preview.6.23329.7 58 07/20/2023
8.0.0-preview.5.23280.8 64 07/12/2023
8.0.0-preview.4.23259.5 58 06/28/2023
8.0.0-preview.3.23174.8 52 06/29/2023
8.0.0-preview.2.23128.3 58 07/13/2023
8.0.0-preview.1.23110.8 60 02/27/2023
7.0.0 59 05/07/2023
7.0.0-rc.2.22472.3 63 07/24/2023
7.0.0-rc.1.22426.10 56 05/01/2023
7.0.0-preview.7.22375.6 63 04/30/2023
7.0.0-preview.6.22324.4 56 10/07/2022
7.0.0-preview.5.22301.12 56 07/17/2023
7.0.0-preview.4.22229.4 63 05/27/2023
7.0.0-preview.3.22175.4 58 07/16/2023
7.0.0-preview.2.22152.2 55 06/13/2023
7.0.0-preview.1.22076.8 57 04/24/2023
6.0.2-mauipre.1.22102.15 59 05/21/2023
6.0.2-mauipre.1.22054.8 55 06/24/2023
6.0.1 41 11/17/2024
6.0.0 2,800 12/07/2021
6.0.0-rc.2.21480.5 49 07/20/2023
6.0.0-rc.1.21451.13 54 08/11/2023
6.0.0-preview.7.21377.19 62 12/20/2021
6.0.0-preview.6.21352.12 45 12/20/2021
6.0.0-preview.5.21301.5 61 05/18/2023
6.0.0-preview.4.21253.7 44 07/19/2023
6.0.0-preview.3.21201.4 50 05/15/2023
6.0.0-preview.2.21154.6 46 07/05/2023
6.0.0-preview.1.21102.12 54 05/17/2023
5.0.0 53 01/27/2023
5.0.0-rc.2.20475.5 53 05/31/2023
5.0.0-rc.1.20451.14 52 05/13/2023
5.0.0-preview.8.20407.11 48 09/10/2022
5.0.0-preview.7.20364.11 57 01/06/2023
5.0.0-preview.6.20305.6 56 08/28/2022
5.0.0-preview.5.20278.1 57 05/15/2023
5.0.0-preview.4.20251.6 64 05/23/2023
5.0.0-preview.3.20215.2 51 05/15/2023
5.0.0-preview.2.20160.3 50 05/19/2023
5.0.0-preview.1.20120.4 61 06/05/2023
3.1.32 55 03/01/2023
3.1.31 52 05/10/2023
3.1.30 53 02/04/2023
3.1.29 52 11/10/2022
3.1.28 62 03/22/2023
3.1.27 55 03/28/2023
3.1.26 50 04/30/2023
3.1.25 53 05/21/2023
3.1.24 67 10/26/2022
3.1.23 58 03/24/2023
3.1.22 53 05/05/2023
3.1.21 53 10/02/2022
3.1.20 48 05/12/2023
3.1.19 58 03/22/2023
3.1.18 46 02/16/2023
3.1.17 56 05/08/2023
3.1.16 58 03/31/2023
3.1.15 57 04/17/2023
3.1.14 58 12/03/2022
3.1.13 56 02/27/2023
3.1.12 63 03/21/2021
3.1.11 62 06/11/2022
3.1.10 52 02/05/2023
3.1.9 53 01/28/2023
3.1.8 57 01/09/2023
3.1.7 53 11/09/2020
3.1.6 51 04/13/2023
3.1.5 55 03/07/2023
3.1.4 57 01/10/2023
3.1.3 53 08/27/2022
3.1.2 52 01/14/2023
3.1.1 50 02/07/2023
3.1.0 55 10/19/2022
3.1.0-preview3.19553.2 52 07/24/2023
3.1.0-preview2.19525.4 56 07/24/2023
3.1.0-preview1.19506.1 47 05/06/2023
3.0.3 52 02/05/2023
3.0.2 62 01/25/2023
3.0.1 52 02/11/2023
3.0.0 61 12/20/2021
3.0.0-rc1.19456.10 51 05/11/2023
3.0.0-preview9.19423.4 51 11/21/2022
3.0.0-preview8.19405.4 58 04/22/2023
3.0.0-preview7.19362.4 60 05/12/2023
3.0.0-preview6.19304.6 64 10/20/2022
3.0.0-preview5.19227.9 54 05/15/2023
3.0.0-preview4.19216.2 52 11/05/2022
3.0.0-preview3.19153.1 61 04/26/2023
3.0.0-preview.19074.2 49 07/18/2023
3.0.0-preview.18572.1 53 05/10/2023
2.2.0 59 12/20/2021
2.2.0-preview3-35497 59 01/21/2023
2.2.0-preview2-35157 52 05/19/2023
2.2.0-preview1-35029 55 01/29/2023
2.1.1 54 01/14/2023
2.1.0 50 01/19/2023
2.1.0-rc1-final 51 02/20/2023
2.1.0-preview2-final 53 02/01/2023
2.1.0-preview1-final 68 12/10/2022
2.0.2 50 03/22/2023
2.0.1 71 12/20/2021
2.0.0 57 06/07/2022
2.0.0-preview2-final 64 03/17/2023
2.0.0-preview1-final 54 04/01/2023
1.1.2 54 10/15/2022
1.1.1 55 02/13/2023
1.1.0 56 12/20/2021
1.1.0-preview1-final 51 04/16/2023
1.0.2 51 10/02/2022
1.0.1 54 12/20/2021
1.0.0 56 12/20/2021
1.0.0-rc2-final 47 02/18/2023
1.0.0-rc1-final 54 01/22/2023