SanitizedHttpLogger 0.0.3

dotnet add package SanitizedHttpLogger --version 0.0.3                
NuGet\Install-Package SanitizedHttpLogger -Version 0.0.3                
此命令旨在在 Visual Studio 的包管理器控制台中使用,因为它使用 NuGet 模块的 Install-Package 版本。
<PackageReference Include="SanitizedHttpLogger" Version="0.0.3" />                
对于支持 PackageReference 的项目,请将此 XML 节复制到项目文件中以引用包。
paket add SanitizedHttpLogger --version 0.0.3                
#r "nuget: SanitizedHttpLogger, 0.0.3"                
#r 指令可用于 F# Interactive 和多语言笔记本。请将其复制到交互式工具或脚本的源代码中以引用包。
// Install SanitizedHttpLogger as a Cake Addin
#addin nuget:?package=SanitizedHttpLogger&version=0.0.3

// Install SanitizedHttpLogger as a Cake Tool
#tool nuget:?package=SanitizedHttpLogger&version=0.0.3                

它是如何工作的

无法配置基于 Microsoft.Extensions.HttpHttpClient 日志记录器的日志模式。必须替换它。

此包用日志记录器替换默认的日志记录器,其

  1. HttpClient 请求上的日志语句数从 4 减少到 2
  2. 确保可以使用可配置的正则表达式模式清理请求-Uri 中的敏感信息,如 api 密钥或令牌

日志输出更改

之前

info: Start processing HTTP request GET https://my.api.com/v1/status?apikey=my-secret-key
info: Sending HTTP request GET https://my.api.com/v1/status?apikey=my-secret-key
info: Received HTTP response headers after 188.6041ms - 200
info: End processing HTTP request after 188.8026ms - 200

之后

info: Sending HTTP request GET https://my.api.com/v1/status?apikey=xxx
info: Received HTTP response GET https://my.api.com/v1/status?apikey=xxx - 200 in 186.4883ms

安装

$ dotnet add package SanitizedHttpLogger

使用方法

通过选项
// This regex pattern will match any part of a string that starts with "apikey=" (in a case-insensitive manner)
// followed by any number of characters that are not an ampersand.
services.UseSanitizedHttpLogger(o => 
    o.RequestUriReplacements.Add("(?i)apikey=[^&]*", "apikey=xxx")
);
通过配置
{
  "SanitizedHttpLoggerOptions": {
    "RequestUriReplacements": {
      "(?i)apikey=[^&]*": "apikey=xxx"
    }
  }
}
services.Configure<SanitizedHttpLoggerOptions>(Configuration);
产品 兼容和额外的目标框架版本。
.NET
.NET Core
.NET Standard
.NET Framework net461被计算过。 net462被计算过。 net463被计算过。 net47被计算过。 net471被计算过。 net472被计算过。 net48是兼容的。 net481被计算过。
MonoAndroid monoandroid被计算过。
MonoMac monomac被计算过。
MonoTouch monotouch被计算过。
Tizen tizen40被计算过。 tizen60被计算过。
Xamarin.iOS xamarinios被计算过。
Xamarin.Mac xamarinmac被计算过。
Xamarin.TVOS xamarintvos被计算过。
Xamarin.WatchOS xamarinwatchos被计算过。
兼容的目标框架
包含的目标框架(在包中)
了解有关目标框架.NET Standard的更多信息。

NuGet 包 (1)

显示依赖 SanitizedHttpLogger 的前 1 个 NuGet 包

下载
Freecurrency-API

这个非官方的(基于RestEase的)客户端可以用于freecurrencyapi(https://freecurrencyapi.com)

GitHub 仓库

此包不依赖任何流行的 GitHub 仓库。

版本 下载 最后更新
0.0.3 550 3/20/2024
0.0.2 91 3/20/2024
0.0.1 150 3/16/2024
0.0.1-preview-04 80 3/14/2024

# 0.0.2 (2024年3月20日)
- #2 添加 SanitizedHttpClientLogger [增强]

完整版本说明可以在此处找到: https://github.com/StefH/SanitizedHttpLogger/blob/main/ReleaseNotes.md