.net 使用NLog Raygun目标时,Raygun不记录版本

k10s72fa  于 2023-04-22  发布在  .NET
关注(0)|答案(1)|浏览(134)

在.NET Framework WebAPI服务上,使用Raygun和NLog。当发生异常时,Raygun跟踪正在执行的程序集的正确版本。但是当通过NLog Raygun目标报告错误时,它只显示Could not find value for entry assembly and version type File
我已经尝试解决这个问题:
1.更新所有软件包
1.在WebApiConfig.Register中设置RaygunWebApiClient.ApplicationVersion,没有成功
1.在nlog.config中设置<target ApplicationVersion="1.1.1.1" />,这实际上可以工作,但它是一个固定的字符串,而不是当前的程序集版本。
1.在nlog.config中设置<target UseExecutingAssemblyVersion="true" />,不起作用
1.在.csproj中为所有(.NET标准)子项目设置AssemblyVersion、FileVersion和Version,但没有成功
不确定,还有什么可以帮助。当我在调用Logger.Error的地方调用Assembly.GetExecutingAssembly().GetName().Version时,它返回正确的版本(但仍然没有记录)。

a6b3iqyw

a6b3iqyw1#

NLog.Raygun-nuget-package支持target-option ApplicationVersionNLog Layout,所以你可以这样做:

<target type="Raygun" name="RaygunTarget" 
        applicationVersion="${gdc:item=AppVersion}" />

你可以在运行时像这样提供NLog GDC值:

string appVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
NLog.GlobalDiagnosticsContext.Set("AppVersion", appVersion);

您也可以考虑使用NLog ${assembly-version}而不是使用NLog GDC。只需指定要从中提取版本信息的程序集Name(如果Entry-Assembly版本不工作)。
注意NLog中的UseExecutingAssemblyVersion。Raygun意味着自动从System.Reflection.Assembly.GetEntryAssembly()解析汇编版本。我猜选项名称是误导性的,
标签:https://github.com/MindscapeHQ/NLog.Raygun

相关问题