Ich verwende Microsoft Application Insights in meiner WPF-App und NLog für die Protokollierung von Ausnahmen und Debug-Informationen. Also habe ich Application Insights NLog Target zur App hinzugefügt. Alle von diesem NLog-Ziel protokollierten Ereignisse enthalten jedoch keine Kontextdaten im Azure-Portal.Wie setze ich Kontext für Application Insights NLog Ziel
Andere Ereignisse, die mit TelemetryClient protokolliert wurden, enthalten diese Daten.
var telemetryClient = new TelemetryClient();
telemetryClient.InstrumentationKey = "xxx";
telemetryClient.Context.User.Id = Environment.UserName;
telemetryClient.Context.Session.Id = Guid.NewGuid().ToString();
//var config = new LoggingConfiguration();
ConfigurationItemFactory.Default.Targets.RegisterDefinition(
"ai",
typeof(ApplicationInsightsTarget)
);
ApplicationInsightsTarget aiTarget = new ApplicationInsightsTarget();
aiTarget.InstrumentationKey = "xxx";
aiTarget.Name = "ai";
LogManager.Configuration.AddTarget("ai", aiTarget);
LogManager.Configuration.AddRule(LogLevel.Info, LogLevel.Info, aiTarget);
LogManager.Configuration.Reload();
LogManager.ReconfigExistingLoggers();
Meine Frage ist - ist es möglich, diese Kontextdaten auch für Ereignisse zu verwenden, die von NLog Target protokolliert werden? Oder, wie kann ich Kontextdaten auch für NLog setzen?