logger-discord-provider 3.0.0

dotnet add package logger-discord-provider --version 3.0.0
                    
NuGet\Install-Package logger-discord-provider -Version 3.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="logger-discord-provider" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="logger-discord-provider" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="logger-discord-provider" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add logger-discord-provider --version 3.0.0
                    
#r "nuget: logger-discord-provider, 3.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package logger-discord-provider@3.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=logger-discord-provider&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=logger-discord-provider&version=3.0.0
                    
Install as a Cake Tool

Discord .NET Logger Provider

NuGet NuGet

A .NET logger provider to send log entries to Discord (https://discordapp.com/) as message in a channel.

For more information about .NET Core logging API visit Logging in .NET Core and ASP.NET Core and Fundamentals of Logging in .NET Core

Target

Discord Webhook Client<br> .NET 8.0

For more information about suported versions visit https://docs.microsoft.com/pt-br/dotnet/standard/net-standard

Installation

NuGet

Install-Package logger-discord-provider

.NET CLI

dotnet add package logger-discord-provider

Configuration

This sample code shows how to add Discord Logger Provider on a .NET project:

using JNogueira.Logger.Discord;

var myDiscordWebhookUrl = "https://discord.com/api/webhooks/...";

var _serviceCollection = new ServiceCollection()
    .AddLogging(c =>
    {
        c.AddDiscordLogger(myDiscordWebhookUrl, config =>
        {
            config.ApplicationName = "Test Application";
            config.EnvironmentName = "Test Environment";
            config.UserName = "TestUserName";
        });
        c.SetMinimumLevel(LogLevel.Trace); //<== Optional
    });

var _serviceProvider = _serviceCollection.BuildServiceProvider();

How to logging

This sample code shows how to add Discord Logger on a ASP.NET Core API controller:

using Microsoft.Extensions.Logging;

namespace My.Sample.Code
{
    public class TodoController : Controller
    {
        private readonly ILogger<TodoController> _logger;

        public TodoController(ITodoRepository todoRepository, ILogger<TodoController> logger)
        {
            _logger = logger;
        }
        
        public IActionResult SayHello()
        {
            ...
            
            // Call "LogInformation" to sendo log messages to Discord channel
            _logger.LogInformation("Hello! This is a sample Discord message sent by ASP.NET Core application!");
            
            ...
        }
    }
}

Message types

Trace

_logger.LogTrace("My trace message is here!");

Trace message

Debug

_logger.LogDebug("My debug message is here!");

Debug message

Information

_logger.LogInformation("My information message is here!");

Debug message

Warning

_logger.LogWarning("My warning message is here!");

Warning message

Error

 _logger.LogError("My error message is here!");

Error message

Critical

 _logger.LogCritical("My critical message is here!");

Error message

Handle an exception!<br/> The attachment file "exception-details.txt" contains more exception details like base exception, stack trace content, exception type, exception extra data information.

try
{
    var i = 0;

    var x = 5 / i;
}
catch (Exception ex)
{
    ex.Data["Extra info 1"] = "Extra info 1 value";
    ex.Data["Extra info 2"] = "Extra info 2 value";

    _logger.LogError(ex, "A exception is handled!");
}

Error message

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 89 6/20/2025
2.3.0 16,571 8/9/2021
2.2.0 870 6/3/2021
2.1.2 778 4/4/2021
2.1.1 1,172 5/11/2020
2.0.1 901 5/10/2020
2.0.0 905 5/10/2020
1.2.2 959 5/9/2020
1.2.1 966 5/1/2020
1.1.1 1,084 1/28/2020
1.1.0 1,014 1/24/2020
1.0.0 914 1/22/2020