Configuration 通过appsettings.json进行Serilog配置以了解应用程序
我正在尝试使用读取应用程序设置并为应用程序洞察设置serilog:。我遇到的问题是,我无法设置ApplicationInsightsEvents调用的最后一个参数,该调用是一个接受LogEvent并返回ITelemetry的函数。如何通过appsettings.json进行设置 基本上,我想替换以下行: log.WriteTo.ApplicationInsightsEvents(instrumentationKey、level、CultureInfo.CurrentCulture、TelemetryConverter.ConvertLogEvents到EnergoVolemetry) 在appsettings.json中有一行Configuration 通过appsettings.json进行Serilog配置以了解应用程序,configuration,azure-application-insights,serilog,appsettings,Configuration,Azure Application Insights,Serilog,Appsettings,我正在尝试使用读取应用程序设置并为应用程序洞察设置serilog:。我遇到的问题是,我无法设置ApplicationInsightsEvents调用的最后一个参数,该调用是一个接受LogEvent并返回ITelemetry的函数。如何通过appsettings.json进行设置 基本上,我想替换以下行: log.WriteTo.ApplicationInsightsEvents(instrumentationKey、level、CultureInfo.CurrentCulture、Telemet
{
"Name": "ApplicationInsights",
"Args": {
"instrumentationKey": "<instrumentationKey>",
"telemetryConverter": "Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights",
"outputTemplate": "[{Component}|{MachineName}|{ThreadId}] {Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] <{SourceContext}> {Message:lj}{NewLine}{Exception}"
}
}
谢谢。在GitHub上回答:。只需编写一个程序集并将最终代码嵌入其中。将接收器配置添加到appsettings.json
{
"Name": "ApplicationInsights",
"Args": {
"instrumentationKey": "<instrumentationKey>",
"telemetryConverter": "Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights",
"outputTemplate": "[{Component}|{MachineName}|{ThreadId}] {Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] <{SourceContext}> {Message:lj}{NewLine}{Exception}"
}
}
如果你能提供一些演示代码,那将有助于其他人更好地理解这个问题。编辑以添加更多信息。