【发布时间】:2018-06-26 04:01:50
【问题描述】:
如何从信息级别日志中过滤或删除不需要的消息? 这是我的日志结果。
日志结果
我只想记录黄色。但是无论我尝试什么,我都无法在上面的黄色之前和之后删除额外的日志。这是我的代码。
public IActionResult Index()
{
_logger.LogInformation("--- THIS IS MY MESSAGE ---");
return View();
}
nlog.config
...
<target xsi:type="File" name="activityLog" fileName="${gdc:item=appbasepath}\Logs\log-activity-${shortdate}.log"
layout="${longdate}|${uppercase:${level}}|${message:raw=true}" />
...
<logger name="*" level="Info" writeTo="activityLog" />
...
【问题讨论】:
-
将
${logger}添加到文件目标布局,以查看记录器名称。然后,您可以使用通配符从不需要的记录器中过滤日志事件。 github.com/nlog/nlog/wiki/Filtering-log-messages
标签: asp.net-core nlog