NLog显示'lambda_method'而不是记录器名称

问题描述 投票:0回答:1

这是我正在使用的布局渲染器字符串:

layout="${longdate}|${uppercase:${level}}|${logger:shortName=True}|${aspnet-Request-UserAgent}|${message} ${exception:format=toString,Data:maxInnerExceptionLevel=10}" 

相关部分为:${logger:shortName=True}

当我在IIS中构建和运行项目的调试版本时,这似乎工作正常:

2019-09-10 08:50:20.8863|INFO|AuthenticationController|39 Win8-64 8.4.0.18|username='testuser' /api/v1/authenticate 

但是当我运行生产版本时,我得到的却是以下内容:

2019-09-10 08:50:20.8863|INFO|lambda_method|39 Win8-64 8.4.0.18|username='testuser' /api/v1/authenticate 

没有得到实际的短记录器名称(AuthenticationController),我最终得到了lambda_method。

我通过以下方式获得记录器:

private readonly Logger _logger = LogManager.GetCurrentClassLogger();

这在ASP.NET Core 2.2项目中,具有NLog.Web.AspNetCore版本4.8.4。我在做什么错?

c# asp.net-core logging nlog
1个回答
0
投票

尝试更新至NLog版本。 4.6.8:

https://www.nuget.org/packages/NLog

遇到“ lambda_method”时,它试图扫描一个更好的记录器名称。

© www.soinside.com 2019 - 2024. All rights reserved.