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

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.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
84
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/b908e913e3befcfe241f3294509e6d9570acc07b
82
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
79
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/1bf292d47ac2a0ebda07d8a3f00355dd01915ad5
77
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/67e04394e98d5bfa6a5684d471a72fcbe30fd587
76
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
76
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/1aa50faa290ecda304507981cd01ed92651d5e34
76
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/f6897a5bb7ca767df8eb465bf15b193c878fffbf
75
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
75
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
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/dotnet/aspnetcore/tree/a5920c6656c9b8cef9e1f769c28062f0ade62f60
72
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
72
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/d4a83b27a44c35c521600e1f30ef688c874415d4
71
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/458d97420a173fe87487b58ec4aa47a4c9dc4710
70
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/80fec4e3edea3972e95885f5c0db6ee06072f917
70
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/561deb05ae2d6680206e3d4a6bc75de699585980
69
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/da6e34b3e17bac8fd1f78c7e76d7ed6192514651
69
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
68

.NET Framework 4.6.2

.NET 8.0

.NET 9.0

.NET 10.0

.NET Standard 2.0

Version Downloads Last updated
10.0.0-preview.3.25171.5 9 4/11/2025
10.0.0-preview.2.25163.2 11 3/26/2025
10.0.0-preview.1.25080.5 18 2/28/2025
9.0.4 11 4/9/2025
9.0.3 13 3/15/2025
9.0.2 16 2/15/2025
9.0.1 29 1/18/2025
9.0.0 25 11/13/2024
9.0.0-rc.2.24473.5 25 10/25/2024
9.0.0-rc.1.24431.7 37 9/12/2024
9.0.0-preview.7.24405.7 31 8/14/2024
9.0.0-preview.6.24327.7 35 7/10/2024
9.0.0-preview.5.24306.7 28 6/14/2024
9.0.0-preview.4.24266.19 30 5/27/2024
9.0.0-preview.3.24172.9 39 4/19/2024
9.0.0-preview.2.24128.5 33 3/16/2024
9.0.0-preview.1.24080.9 39 2/24/2024
8.0.1 31 10/15/2024
8.0.0 45 11/18/2023
8.0.0-rc.2.23479.6 51 10/28/2023
8.0.0-rc.1.23419.4 41 9/15/2023
8.0.0-preview.7.23375.6 58 8/22/2023
8.0.0-preview.6.23329.7 54 7/20/2023
8.0.0-preview.5.23280.8 47 7/17/2023
8.0.0-preview.4.23259.5 58 5/20/2023
8.0.0-preview.3.23174.8 57 5/12/2023
8.0.0-preview.2.23128.3 70 3/25/2023
8.0.0-preview.1.23110.8 48 2/23/2023
7.0.0 80 12/3/2022
7.0.0-rc.2.22472.3 66 11/12/2022
7.0.0-rc.1.22426.10 53 9/15/2022
7.0.0-preview.7.22375.6 59 9/15/2022
7.0.0-preview.6.22324.4 53 9/15/2022
7.0.0-preview.5.22301.12 57 6/26/2022
7.0.0-preview.4.22229.4 66 7/3/2022
7.0.0-preview.3.22175.4 58 7/3/2022
7.0.0-preview.2.22152.2 58 7/3/2022
7.0.0-preview.1.22076.8 77 7/3/2022
6.0.2-mauipre.1.22102.15 58 7/3/2022
6.0.2-mauipre.1.22054.8 56 7/3/2022
6.0.1 20 11/14/2024
6.0.0 45 7/3/2022
6.0.0-rc.2.21480.5 61 7/3/2022
6.0.0-rc.1.21451.13 46 7/3/2022
6.0.0-preview.7.21377.19 69 7/3/2022
6.0.0-preview.6.21352.12 65 7/3/2022
6.0.0-preview.5.21301.5 68 7/3/2022
6.0.0-preview.4.21253.7 70 7/3/2022
6.0.0-preview.3.21201.4 45 7/3/2022
6.0.0-preview.2.21154.6 57 7/3/2022
6.0.0-preview.1.21102.12 66 7/3/2022
5.0.0 45 7/3/2022
5.0.0-rc.2.20475.5 75 7/3/2022
5.0.0-rc.1.20451.14 67 7/3/2022
5.0.0-preview.8.20407.11 71 7/3/2022
5.0.0-preview.7.20364.11 68 7/3/2022
5.0.0-preview.6.20305.6 73 7/3/2022
5.0.0-preview.5.20278.1 57 7/3/2022
5.0.0-preview.4.20251.6 66 7/3/2022
5.0.0-preview.3.20215.2 67 7/3/2022
5.0.0-preview.2.20160.3 59 7/3/2022
5.0.0-preview.1.20120.4 68 7/3/2022
3.1.32 49 2/21/2023
3.1.31 57 12/3/2022
3.1.30 56 10/28/2022
3.1.29 56 9/15/2022
3.1.28 71 9/15/2022
3.1.27 53 9/15/2022
3.1.26 51 7/3/2022
3.1.25 50 7/3/2022
3.1.24 59 7/3/2022
3.1.23 60 7/3/2022
3.1.22 60 7/3/2022
3.1.21 62 7/3/2022
3.1.20 49 7/3/2022
3.1.19 60 7/3/2022
3.1.18 47 7/3/2022
3.1.17 82 7/3/2022
3.1.16 52 7/3/2022
3.1.15 59 7/3/2022
3.1.14 54 7/3/2022
3.1.13 51 7/3/2022
3.1.12 63 7/3/2022
3.1.11 55 7/3/2022
3.1.10 49 7/3/2022
3.1.9 70 7/3/2022
3.1.8 60 7/3/2022
3.1.7 56 7/3/2022
3.1.6 64 7/3/2022
3.1.5 55 7/3/2022
3.1.4 73 7/3/2022
3.1.3 43 7/3/2022
3.1.2 59 7/3/2022
3.1.1 47 7/3/2022
3.1.0 61 7/3/2022
3.1.0-preview3.19553.2 46 7/3/2022
3.1.0-preview2.19525.4 60 7/3/2022
3.1.0-preview1.19506.1 57 7/3/2022
3.0.3 51 7/3/2022
3.0.2 55 7/3/2022
3.0.1 47 7/3/2022
3.0.0 53 6/13/2022
3.0.0-rc1.19456.10 69 7/3/2022
3.0.0-preview9.19423.4 63 7/3/2022
3.0.0-preview8.19405.4 76 7/3/2022
3.0.0-preview7.19362.4 60 7/3/2022
3.0.0-preview6.19304.6 59 7/3/2022
3.0.0-preview5.19227.9 54 7/3/2022
3.0.0-preview4.19216.2 51 7/3/2022
3.0.0-preview3.19153.1 63 7/3/2022
3.0.0-preview.19074.2 77 7/3/2022
3.0.0-preview.18572.1 71 7/3/2022
2.2.0 69 7/3/2022
2.2.0-preview3-35497 60 7/3/2022
2.2.0-preview2-35157 47 7/3/2022
2.2.0-preview1-35029 42 7/3/2022
2.1.1 57 7/3/2022
2.1.0 81 7/3/2022
2.1.0-rc1-final 43 7/3/2022
2.1.0-preview2-final 54 7/3/2022
2.1.0-preview1-final 51 7/3/2022
2.0.2 45 7/3/2022
2.0.1 61 7/3/2022
2.0.0 62 7/3/2022
2.0.0-preview2-final 70 7/3/2022
2.0.0-preview1-final 49 7/3/2022
1.1.2 77 7/3/2022
1.1.1 50 7/3/2022
1.1.0 41 7/3/2022
1.1.0-preview1-final 44 7/3/2022
1.0.2 79 7/3/2022
1.0.1 59 7/3/2022
1.0.0 59 7/3/2022
1.0.0-rc2-final 51 7/3/2022
1.0.0-rc1-final 54 7/3/2022