I'm using Microsoft Application Insights in my WPF app and NLog for logging exceptions and debug informations. So, I added Application Insights NLog Target to the app. But all events logged by this NLog target doesn't contain context data on Azure portal.
Other events, logged using TelemetryClient contains these data.
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();
My question is - it is possible to use this context data also for events logged by NLog Target? Or, how can I set context data also for NLog?