NLog error when opening Tentacle Manager

We recently upgraded to NLog 4.4.2. As part of our Logging Event and Error Info to the DB, we also wanted to include the user identity for web-based applications that we’re using Windows authentication. So, we added this capability to our web projects by adding the NLog.Web nugget package. Then, to simplify things we moved all the NLog configuration settings from individual web/app files to the machine.config on the server.

This is the parameter that we added:

However, I believe Octopus Tentacle is using an older version of NLog where this is not supported. I get the following error when attempting to open Tentacle Manager:
System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for nlog: Error when setting property ‘Layout’ on NLog.Targets.DatabaseParameterInfo (C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config line 154) —> NLog.NLogConfigurationException: Error when setting property ‘Layout’ on NLog.Targets.DatabaseParameterInfo —> System.ArgumentException: LayoutRenderer cannot be found: 'aspnet-user-identity’
at NLog.Config.Factory`2.CreateInstance(String name)
at NLog.Layouts.LayoutParser.ParseLayoutRenderer(ConfigurationItemFactory configurationItemFactory, SimpleStringReader sr)
at NLog.Layouts.LayoutParser.CompileLayout(ConfigurationItemFactory configurationItemFactory, SimpleStringReader sr, Boolean isNested, String& text)
at NLog.Layouts.SimpleLayout.set_Text(String value)
at NLog.Internal.PropertyHelper.TryNLogSpecificConversion(Type propertyType, String value, Object& newValue, ConfigurationItemFactory configurationItemFactory)
at NLog.Internal.PropertyHelper.SetPropertyFromString(Object o, String name, String value, ConfigurationItemFactory configurationItemFactory)
— End of inner exception stack trace —
at NLog.Internal.PropertyHelper.SetPropertyFromString(Object o, String name, String value, ConfigurationItemFactory configurationItemFactory)
at NLog.Config.XmlLoggingConfiguration.ConfigureObjectFromAttributes(Object targetObject, NLogXmlElement element, Boolean ignoreType)
at NLog.Config.XmlLoggingConfiguration.SetPropertyFromElement(Object o, NLogXmlElement element)
at NLog.Config.XmlLoggingConfiguration.ParseTargetElement(Target target, NLogXmlElement targetElement)
at NLog.Config.XmlLoggingConfiguration.ParseTargetsElement(NLogXmlElement targetsElement)
at NLog.Config.XmlLoggingConfiguration.ParseNLogElement(NLogXmlElement nlogElement, String baseDirectory)
at NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader, String fileName, Boolean ignoreErrors)
at NLog.Config.XmlLoggingConfiguration…ctor(XmlElement element, String fileName)
at NLog.Config.ConfigSectionHandler.Create(XmlNode section, IAppDomain appDomain)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithFullTrust(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
at System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
at System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader, String filename, Int32 line)
— End of inner exception stack trace —
at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at NLog.LogFactory.get_Configuration()
at NLog.LogFactory.GetLogger(LoggerCacheKey cacheKey)
at Octopus.Shared.Diagnostics.NLogAppender…ctor() in Y:\work\refs\tags\3.3.15\source\Octopus.Shared\Diagnostics\NLogAppender.cs:line 14
at Octopus.Shared.Diagnostics.LoggingModule.Load(ContainerBuilder builder) in Y:\work\refs\tags\3.3.15\source\Octopus.Shared\Diagnostics\LoggingModule.cs:line 12
at Autofac.Module.Configure(IComponentRegistry componentRegistry)
at Autofac.ContainerBuilder.Build(IComponentRegistry componentRegistry, Boolean excludeDefaultModules)
at Autofac.ContainerBuilder.Build(ContainerBuildOptions options)
at Octopus.Manager.Tentacle.App.ConfigureContainer(String command, String[] args) in Y:\work\refs\tags\3.3.15\source\Octopus.Manager.Tentacle\App.xaml.cs:line 80
at Octopus.Manager.Tentacle.App.OnStartup(StartupEventArgs e) in Y:\work\refs\tags\3.3.15\source\Octopus.Manager.Tentacle\App.xaml.cs:line 53
at System.Windows.Application.<.ctor>b__1(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

I have confirmed that this problem is resolved by removing the aspnet-user-identity param from the machine.config. Other than move the NLog configuration settings back to the individual web/app config files, do you have any other recommendation?

Hi Sbenners,

Thanks for getting in touch! It’s not the older version of NLog that is causing the trouble (our current releases use 4.0.1 I believe), it’s that we don’t use NLog.Web, and as such don’t include NLog.Web.dll in our installation. I’ve created a GitHub issue to get the NLog.Web package added for cases like yours. You can track it here;

In the meantime, in my testing, just dropping NLog.Web.dll into the Octopus install directory next to NLog.dll is enough for .net to find it when we try to do our NLog initialisation, you might want to test that and if it works use that until we get NLog.Web added and you can upgrade.

Hope that helps!

Mark

Thank you. I’ll take this into consideration.