BorgNet.Serilog
1.0.0
dotnet add package BorgNet.Serilog --version 1.0.0
NuGet\Install-Package BorgNet.Serilog -Version 1.0.0
<PackageReference Include="BorgNet.Serilog" Version="1.0.0" />
paket add BorgNet.Serilog --version 1.0.0
#r "nuget: BorgNet.Serilog, 1.0.0"
// Install BorgNet.Serilog as a Cake Addin #addin nuget:?package=BorgNet.Serilog&version=1.0.0 // Install BorgNet.Serilog as a Cake Tool #tool nuget:?package=BorgNet.Serilog&version=1.0.0
Nuget引用以下包:
Serilog.AspNetCore Serilog.Sinks.Http Serilog.Sinks.File Serilog.Sinks.Async Serilog.Sinks.Console 使用 appsetting.json
"Serilog": { "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File", "Serilog.Sinks.Http", "Serilog.Sinks.Async" ], "MinimumLevel": { "Default": "Information", "Override": { "Microsoft": "Warning", "Microsoft.Hosting": "Information" } }, "Properties": { "Application": "XXX.API" }, "WriteTo:Async": { "Name": "File", "Args": { "path": "Logs/.txt", "rollingInterval": "Day", "retainedFileCountLimit": "31", "retainedFileTimeLimit": "10.00:00:00", "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u4}] [{SourceContext}] {Message:lj}{NewLine}{Exception}" } }, "WriteTo:Console": { "Name": "Console", "Args": { "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u4}] [{SourceContext}] {Message:lj}{NewLine}{Exception}"
}
},
"WriteTo:Http": {
"Name": "Http",
"Args": {
"requestUri": "http://127.0.0.1:9988",
"queueLimitBytes": null
}
}
启用服务 没有基于BorgNet.Core 的使用场景,必须手动进行初始化,如下: 如下: Program.cs在 builder.Build()前增加如下:
// 使用日志 builder.Host.UseSerilog((context, logger) ⇒ { logger.ReadFrom.Configuration(context.Configuration); logger.Enrich.FromLogContext(); });
基于BorgNet.Core的使用,只需要添加引用后配置以上appsetting.josn配置以上节点即可 使用说明
private readonly ILogger<LoginController> _logger;//日志
//依赖注入
public LoginController(ILogger<LoginController> logger)
{
_logger = logger;
}
/// <summary>
/// 用户登录
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
[HttpPost]
public string Login(string user)
{
_logger.LogError($"{System.Reflection.MethodBase.GetCurrentMethod().Name} Args:{user.ToString()}");
return "ok";
}
更新中...
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.0
- BorgNet.Startup (>= 1.0.0)
- Serilog.AspNetCore (>= 6.0.1)
- Serilog.Sinks.Async (>= 1.5.0)
- Serilog.Sinks.Elasticsearch (>= 8.4.1)
- Serilog.Sinks.File (>= 5.0.0)
- Serilog.Sinks.Http (>= 8.0.0)
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 |
---|---|---|
1.0.0 | 196 | 1/29/2023 |