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

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.
1,621
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
1,591
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
68
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
67
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
66
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
64
Microsoft.AspNetCore
Microsoft.AspNetCore
61
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
61
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
59
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications. When using NuGet 3.x this package requires at least version 3.4.
59
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
58
Microsoft.AspNetCore
Microsoft.AspNetCore
56
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
55
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
55
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications. When using NuGet 3.x this package requires at least version 3.4.
54
Microsoft.AspNetCore
Microsoft.AspNetCore
53

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