I’m having trouble running a program that uses NLog. I’m getting an exception during initialization that ends with:
—> NLogConfigurationException: Exception occurred when loading configuration …
—> System.ArgumentException: Target cannot be found: ‘ColoredConsole’
I also have the full exception text.
I’m fairly sure it’s not a problem with my configuration, because a) I can use the same config on other machines without a problem, and b) I trimmed it down to the dumbest config I could and I still see the problem:
NLog configuration:
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="console" xsi:type="ColoredConsole" layout="test" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="console" />
</rules>
</nlog>
I have also tried other target types, including Console and File, with the same result.
The fact that it’s just this machine suggests a permission issue, but I’ve tried supplying permissions and administrator rights everywhere I can think of, I’ve tried running it as a different account and from different directories – all without any change. The system is running Server 2008 R2, fwiw.
What might I have missed?
Server 2008 R2 comes with .NET 3.5 SP1, but it is not enabled by default. Apparently .NET 2 is enabled by default, however, which is why I was able to execute some of my .NET code without receiving a more cryptic error.
Enabling .NET 3.5 via the Add Features dialog allowed NLog to run successfully.