gpt4 book ai didi

nlog - 如何将 formatProvider 参数添加到 NLog.LogEventInfo.Create 方法?

转载 作者:行者123 更新时间:2023-12-02 00:28:45 25 4
gpt4 key购买 nike

我有以下 NLog 2.0 代码来记录异常:

Dim theEvent = NLog.LogEventInfo.Create(NLog.LogLevel.Error, loggerName, message, ex)

升级到 NLog 4.1 后,我看到以下警告:

Function Create(logLevel As LogLevel, loggerName As String, message As String, exception As Exception) As LogEventInfo' is obsolete: 'use Create(LogLevel logLevel, string loggerName, Exception exception, IFormatProvider formatProvider, string message)'

...它要求我添加 IFormatProvider formatProvider 作为参数。我应该在那里添加什么?

Dim theEvent = NLog.LogEventInfo.Create(NLog.LogLevel.Error, loggerName, ex, ???, message)

最佳答案

您可以安全地使用null ,来自 System.Globalization.CultureInfo 之一成员(可以找到一个很好的指南 here )或根据您的需要创建您自己的自定义格式提供程序。

当前的实现(从 GitHub 上的 v.4.1.2 开始)将简单地使用 CultureInfo.CurrentCulture如果FormatProvider属性是 null .

关于nlog - 如何将 formatProvider 参数添加到 NLog.LogEventInfo.Create 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32657595/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com