Microsoft.Extensions.Logging.Console 9.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.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
49
Microsoft.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
46
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
42
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
40
Microsoft.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
36
Microsoft.AspNetCore.App
Microsoft.AspNetCore.App
35
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications. This package was built from the source at: https://github.com/aspnet/javascriptservices/tree/3265b92086cb62a98d7a486f9e8f81a77ef56afc
34
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
34
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
33
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
32
Microsoft.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
32
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
31
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications. When using NuGet 3.x this package requires at least version 3.4.
31
Microsoft.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download. This package was built from the source at: https://github.com/aspnet/Universe/tree/244e037a222a7cd0a17feafb7f3a625fde40de97
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/bd1e14b7d16b798de8a874189c89afed755a266c
26
Microsoft.Extensions.Hosting
.NET Core hosting and startup infrastructures for applications.
25
Microsoft.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
24
Microsoft.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
23

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

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