我想记录请求持续时间。为此,我有一个中间件,并将OnActionExecuted经过的时间分配给变量,并尝试通过 lambda 函数使用自定义布局渲染来注册它
requestDuration = _stopWatch.ElapsedMilliseconds;
LayoutRenderer.Register("requestDuration", logEvent => requestDuration);在我的 nlog.config 上,我有以下内容
<column name ="RequestDuration" layout="${requestDuration}" quoting="Nothing"/>NLog 抱怨说这将被忽略:
Error Error parsing layout requestDuration will be ignored. Exception: System.ArgumentException: LayoutRenderer cannot be found: 'requestDuration' at NLog.Config.Factory`2.CreateInstance(String itemName) at NLog.Layouts.LayoutParser.GetLayoutRenderer(ConfigurationItemFactory configurationItemFactory, String name)
我是否在错误的位置注册了layoutRenderer?
请注意,我试图有一列是请求持续时间,而不是简单地在日志消息上写下该时间
POPMUISE
缥缈止盈
随时随地看视频慕课网APP
相关分类