TencentCloudLogger 0.0.7

.NET 6.0
dotnet add package TencentCloudLogger --version 0.0.7
NuGet\Install-Package TencentCloudLogger -Version 0.0.7
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="TencentCloudLogger" Version="0.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TencentCloudLogger --version 0.0.7
#r "nuget: TencentCloudLogger, 0.0.7"
#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.
// Install TencentCloudLogger as a Cake Addin
#addin nuget:?package=TencentCloudLogger&version=0.0.7

// Install TencentCloudLogger as a Cake Tool
#tool nuget:?package=TencentCloudLogger&version=0.0.7

TencentCloudLogger

注意

  1. 该项目封装的是 2017 版的 API,非最新的 3.0 版 API,官方地址:https://cloud.tencent.com/document/api/614/16873
  2. 2017 版 API 官方截至 2022-1-9 给出的地址是 <Region>.cls.tencentyun.com ,经测试容易出现503错误,可使用 <Region>.cls.tencentcs.com 代替。

使用方法

  1. appsettings.json 中添加如下配置项:
{
  "TencentCloudLogger": {
    "Level": "Information",//记录的最低日志级别
    "ApiHost": "http://ap-shanghai.cls.tencentcs.com", //请求地址 
    "SecretId": "AKID....",
    "SecretKey": "sVrw...",
    "Topic": "4807fc45-xxxx-xxxx-xxxxxxxxxxxx" //日志主题ID
  }
}
  1. Startup.cs 文件中 ConfigureServices 方法里依赖注入:
var option = Configuration.GetSection("TencentCloudLogger").Get<TCloudOption>();
services.AddTencentCloudLogger(option);

或者在 Program.cs 文件中 :

var option = builder.Configuration.GetSection("TencentCloudLogger").Get<TCloudOption>();
builder.Services.AddTencentCloudLogger(option);
  1. 调用:
private readonly ILogger _logger;

public Test(ILogger<TCloudLogger> logger)
{
    _logger = logger;
}

_logger.LogInformation("Test");
_logger.LogError("Test");
_logger.LogDebug("Test");
_logger.LogWarning("Test");
...
...
...

Product Versions
.NET net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
Compatible target framework(s)
Additional computed target framework(s)
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
0.0.7 355 1/21/2022
0.0.6 164 1/10/2022
0.0.5 209 8/25/2021