Skip to content

Commit

Permalink
add support for .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
jedipi committed Mar 30, 2024
1 parent 405bbc1 commit f94b8f2
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
working-directory: src
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog

### 2.0.0 - 2023-01-08
### 5.0.0 - 2023-01-08
- Add Support for .NET 8
- Remove support for .Net Core 3.1, .Net Framework

### 4.0.0 - 2023-01-08
- Add Support for netstandard2.1

### 4.0.0 - 2023-01-08
- Support .Net 7.0

### 3.0.0 - 2022-06-04
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ A NLog target that write log to Microsoft Teams channel via O365 Webhook Connect

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


Expand Down
108 changes: 108 additions & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
[![NuGet版本(NLog.Targets.MicrosoftTeams)](https://img.shields.io/nuget/v/NLog.Targets.MicrosoftTeams.svg?style=flat)](https://www.nuget.org/packages/NLog.Targets.MicrosoftTeams)
[![构建状态](https://dev.azure.com/jedipi/NLog.Targets.MicrosoftTeams/_apis/build/status/jedipi.NLog.Targets.MicrosoftTeams?branchName=master)](https://dev.azure.com/jedipi/NLog.Targets.MicrosoftTeams/_build/latest?definitionId=1&branchName=master)
[![.NET](https://github.com/jedipi/NLog.Targets.MicrosoftTeams/actions/workflows/dotnet.yml/badge.svg?branch=master)](https://github.com/jedipi/NLog.Targets.MicrosoftTeams/actions/workflows/dotnet.yml)
![GitHub](https://img.shields.io/github/license/jedipi/NLog.Targets.MicrosoftTeams)
[![NuGet下载](https://img.shields.io/nuget/dt/NLog.Targets.MicrosoftTeams)](https://www.nuget.org/packages/NLog.Targets.MicrosoftTeams)
[![点击计数](http://hits.dwyl.com/jedipi/NLogTargetsMicrosoftTeams.svg)](https://github.com/jedipi/NLog.Targets.MicrosoftTeams)
##### 构建历史
[![构建历史](https://buildstats.info/github/chart/jedipi/NLog.Targets.MicrosoftTeams?branch=master)](https://github.com/jedipi/NLog.Targets.MicrosoftTeams/actions?query=branch%3Amaster)
##### Stargazers & Forkers
[![Stargazers名册 @jedipi/NLog.Targets.MicrosoftTeams](https://reporoster.com/stars/jedipi/NLog.Targets.MicrosoftTeams)](https://github.com/jedipi/NLog.Targets.MicrosoftTeams/stargazers)
[![Forkers名册 @jedipi/NLog.Targets.MicrosoftTeams](https://reporoster.com/forks/jedipi/NLog.Targets.MicrosoftTeams)](https://github.com/jedipi/NLog.Targets.MicrosoftTeams/network/members)


# NLog.Targets.MicrosoftTeams
![](image/nlog-teams.png)
<br>
一个NLog目标,通过O365 Webhook连接器将日志写入Microsoft Teams频道。

- 支持自定义ApplicationName布局
- 支持自定义Teams消息卡片标题
- 支持.Net Framework、.Net Core、.Net 5/6/7/8和.Net Standard
- 可以在NLog.conf、app.config或appsetting.json中配置你的Webhook URL


关于Teams中的webhhoks的更多信息请阅读:
- https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/what-are-webhooks-and-connectors
- https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook

# 输出
![示例NLog.Targets.MicrosoftTeams输出](image/output.png)

# 入门
### 安装

将NLog.Targets.MicrosoftTeams包从nuget添加到你的项目中。

```cmd
PM> Install-Package NLog.Targets.MicrosoftTeams
<br>
### Usage
```xml
<!-- 示例 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="你的Teams频道Webhook" />
</appSettings>
</configuration>
```



NLog.config
```xml
NLog.config
<!-- 从app.config获取Webhook URL的示例 -->
<!-- 将日志写入Microsoft Teams -->
<target xsi:type="MicrosoftTeams, NLog.Targets.MicrosoftTeams"
name="msTeams"
WebhookUrl="${appsetting:name=Logging.TeamsUrl}"
ApplicationName="你的应用名称"
CardTitle="标题 - ${level:uppercase=true}: ${date} - [${logger}]"
layout="[${level:uppercase=true}] ${logger} - ${message} ${all-event-properties}"
/>
```

```xml
<!-- 从appsetting.json获取Webhook URL的示例 -->
<!-- 将日志写入Microsoft Teams -->
<target xsi:type="MicrosoftTeams, NLog.Targets.MicrosoftTeams"
name="msTeams"
WebhookUrl="${configsetting:name=Logging.TeamsUrl}"
ApplicationName="你的应用名称"
CardTitle="标题 - ${level:uppercase=true}: ${date} - [${logger}]"
layout="[${level:uppercase=true}] ${logger} - ${message} ${all-event-properties}"
/>
```

```xml

<!-- 在nlog.conf内设置Webhook URL的示例 -->
<!-- 将日志写入Microsoft Teams -->
<target xsi:type="MicrosoftTeams, NLog.Targets.MicrosoftTeams"
name="msTeams"
WebhookUrl="你的Teams Webhook URL在这里"
ApplicationName="你的应用名称"
CardTitle="标题 - ${level:uppercase=true}: ${date} - [${logger}]"
layout="[${level:uppercase=true}] ${logger} - ${message} ${all-event-properties}"
/>

```


# Support
如果你从我创建的任何内容中获得了价值,就请我喝一杯吧。

[![请我喝一杯](https://www.lifeofanarchitect.com/wp-content/uploads/2017/12/Ko-Fi-Image-Buy-Me-a-Beer.png)](https://www.paypal.com/donate/?hosted_button_id=WW82TCHX3P6EG)





15 changes: 12 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4

trigger:
- master
branches:
include:
- master
paths:
include:
- NLog.Targets.MicrosoftTeams
exclude:
- '*.yaml'
- '*.yml'
- '*.md'

pool:
vmImage: 'windows-latest'
Expand All @@ -16,9 +25,9 @@ variables:

steps:
- task: UseDotNet@2
displayName: 'Use dotnet 7'
displayName: 'Use dotnet 8'
inputs:
version: '7.0.x'
version: '8.0.x'

- task: NuGetToolInstaller@1

Expand Down
1 change: 1 addition & 0 deletions src/NLog.Targets.MicrosoftTeams.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "misc", "misc", "{4A422B13-E
ProjectSection(SolutionItems) = preProject
..\CHANGELOG.md = ..\CHANGELOG.md
..\README.md = ..\README.md
..\README_zh.md = ..\README_zh.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "pipeline", "pipeline", "{240274A7-1530-49FB-B96F-D06B1A561A84}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net472;netcoreapp3.1;net5.0;net6;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.1;net472;net6;net7.0;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>A NLog target that writes to Microsoft Teams Channel via O365 Webhook Connector.</Description>
<Copyright>Copyright © Kin Tam 2022</Copyright>
Expand All @@ -15,7 +15,7 @@
<RepositoryUrl>https://github.com/jedipi/NLog.Targets.MicrosoftTeams</RepositoryUrl>
<PackageIcon>nlog-teams.png</PackageIcon>
<PackageReadmeFile></PackageReadmeFile>
<PackageReleaseNotes>support .NET 7.0</PackageReleaseNotes>
<PackageReleaseNotes>add support for net8</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit f94b8f2

Please sign in to comment.