Skip to content

santifdezmunoz/NLog.Targets.MicrosoftTeams

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NuGet version (NLog.Targets.MicrosoftTeams) Build Status .NET GitHub NuGet downloads HitCount

Build History

Build History

NLog.Targets.MicrosoftTeams


A NLog target that write log to Microsoft Teams channel via O365 Webhook Connector.

  • Support custom ApplicationName layout
  • Support custom Teams message card title
  • Support .Net Framework, .Net Core, .Net 5, and .Net Standard
  • Options to configure your Webhook URL in NLog.conf, app.config, or appsetting.json

For more Information about webhhoks in Teams read:

Output

Example NLog.Targets.MicrosoftTeams output

Getting Started

Installation

Add the NLog.Targets.MicrosoftTeams package from nuget to your project.

PM> Install-Package NLog.Targets.MicrosoftTeams

Usage

<!-- Example app.config -->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
    </startup>
  <appSettings>
    <add key="Logging.TeamsUrl" value="Your Teams Channel Webhook" />
  </appSettings>
</configuration>

NLog.config

<!-- Example for getting Webhook URL from app.config -->
<!-- write logs to Microsoft Teams -->
<target xsi:type="MicrosoftTeams, NLog.Targets.MicrosoftTeams" 
         name="msTeams" 
         WebhookUrl="${appsetting:name=Logging.TeamsUrl}"          
         ApplicationName="Your Application Name"
         CardTitle="Title - ${level:uppercase=true}: ${date} - [${logger}]"
         layout="[${level:uppercase=true}] ${logger} - ${message} ${all-event-properties}"
    />
<!-- Example for getting Webhook URL from appsetting.json -->
<!-- write logs to Microsoft Teams -->
<target xsi:type="MicrosoftTeams, NLog.Targets.MicrosoftTeams" 
         name="msTeams" 
         WebhookUrl="${configsetting:name=Logging.TeamsUrl}"          
         ApplicationName="Your Application Name"
         CardTitle="Title - ${level:uppercase=true}: ${date} - [${logger}]"
         layout="[${level:uppercase=true}] ${logger} - ${message} ${all-event-properties}"
    />
<!-- Example for setting Webhook URL inside nlog.conf -->
<!-- write logs to Microsoft Teams -->
<target xsi:type="MicrosoftTeams, NLog.Targets.MicrosoftTeams" 
         name="msTeams" 
         WebhookUrl="Your Teams Webhook URL here"          
         ApplicationName="Your Application Name"
         CardTitle="Title - ${level:uppercase=true}: ${date} - [${logger}]"
         layout="[${level:uppercase=true}] ${logger} - ${message} ${all-event-properties}"
    />

Support

If you've got value from any of the content which I have created, then I would also very much appreciate your support by buying me a beer.

buy me a beer

About

A NLog target that writes to Microsoft Teams Channel via O365 Webhook Connector.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%