Exceptionless.Net
Exceptionless.Net copied to clipboard
NLog - Ability to add fields from Code
I dont use nlog.config file for configuring the logger. All the configuration is done on the fly from the code. I'm trying to add additional field to the ExceptionlessTarget object but I cannot, because the Fields property is readonly. Can you make this property non readonly so that we can add values to it dynamically ?
Here is how I configure using the code :
if (logConfig.EnableExceptionlessTarget) { var target = new Exceptionless.NLog.ExceptionlessTarget { Name = "ExceptionlessTarget", ApiKey = logConfig.ExceptionlessApiKey, ServerUrl = logConfig.ExceptionlessServerUrl }; var aWrapper = new AsyncTargetWrapper { Name = "ExceptionLessTargetWrapper_1", OverflowAction = AsyncTargetWrapperOverflowAction.Grow, WrappedTarget = target }; config.AddTarget(AppLoggerName + "-exceptionLess", aWrapper); var rule = new LoggingRule(AppLoggerName, LogLevel.Trace, aWrapper); config.LoggingRules.Add(rule); }
That sounds reasonable, can you please submit a pr for this and some sample code to our sample so we can see this in action and ensure we don't break it going forward :).
I've fixed this in the latest nightly build.