![](/img/trans.png)
[英]How to configure and view logging using Microsoft.Extensions.Logging
[英]How do I log a custom field in NLog to database using Microsoft.Extensions.Logging?
我将 Microsoft.Extensions.Logging 与 NLog 一起使用。 我的应用是 .NET Core 3.1。
我想使用自定义字段扩展日志记录。
有可能还是我需要直接使用 NLog?
<parameter name="@custom_guid" layout="${custom_guid}"/>
var config = new Dictionary<string, object>();
config.Add("custom_guid", "test");
_logger.LogInformation("Test message", config);
你可以这样做:
var config = new Dictionary<string, object>();
config.Add("custom_guid", "test");
using (_logger.BeginScope(config))
{
_logger.LogInformation("Test message");
}
并使用${mdlc:custom_guid}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.