```c#
private void WriteToOutputWithColor(LogEventInfo logEvent, string message)
// this will enable word highlighting if n, event without word highlighting rules:
bool wordHighlighting = !ReferenceEquals(colorMessage, message) || message?.IndexOf('n') >= 0;
WriteToOutputWithPrinter:
ColorizeEscapeSequences(_consolePrinter, consoleWriter, colorMessage, oldForegroundColor, oldBackgroundColor, rowForegroundColor, rowBackgroundColor);
var foreground = (ConsoleOutputColor)(c2 - 'A');
consolePrinter.ChangeForegroundColor(consoleWriter, currentForegroundColor);
stacktrace:
The ConsoleColor enum value was not defined on that enum. Please use a defined color from the enum.
at System.ConsolePal.ConsoleColorToColorAttribute(ConsoleColor color, Boolean isBackground)
at System.ConsolePal.set_ForegroundColor(ConsoleColor value)
at NLog.Targets.ColoredConsoleSystemPrinter.ChangeForegroundColor(TextWriter consoleWriter, Nullable1 foregroundColor)
at NLog.Targets.ColoredConsoleTarget.ColorizeEscapeSequences(IColoredConsolePrinter consolePrinter, TextWriter consoleWriter, String message, Nullable1 defaultForegroundColor, Nullable1 defaultBackgroundColor, Nullable1 rowForegroundColor, Nullable1 rowBackgroundColor)
at NLog.Targets.ColoredConsoleTarget.WriteToOutputWithPrinter(TextWriter consoleStream, String colorMessage, Nullable1 newForegroundColor, Nullable`1 newBackgroundColor, Boolean wordHighlighting)
at NLog.Targets.ColoredConsoleTarget.WriteToOutputWithColor(LogEventInfo logEvent, String message)
at NLog.Targets.ColoredConsoleTarget.WriteToOutput(LogEventInfo logEvent, String message)
at NLog.Targets.Target.Write(AsyncLogEventInfo logEvent)
at NLog.Targets.Target.WriteAsyncThreadSafe(AsyncLogEventInfo logEvent)
at NLog.Targets.Target.WriteAsyncLogEvent(AsyncLogEventInfo logEvent)
at NLog.LoggerImpl.WriteToTargetWithFilterChain(Target target, FilterResult result, LogEventInfo logEvent, AsyncContinuation onException)
at NLog.LoggerImpl.Write(Type loggerType, TargetWithFilterChain targetsForLevel, LogEventInfo logEvent, LogFactory factory)
```
Hi! Thanks for opening your first issue here! Please make sure to follow the issue template - so we could help you better!
Thank you for reporting this. Possible you could paste your NLog.config-file into the issue? And maybe a small code-example that triggers this exception? It would really help a lot.
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="true"
internalLogLevel="Off" internalLogFile="c:\dibs\nlog-internal.log">
optimizeBufferReuse="true" />
<target name="fileIfApplicable" xsi:type="FilteringWrapper"
condition="'${environment:DOTNET_RUNNING_IN_CONTAINER}' != 'true'">
<target name="file"
xsi:type="File"
fileName="${configsetting:name=LogFolder}\${appName}.${date:format=yyyyMMddHH}.json.log"
maxArchiveFiles="72"
encoding="utf-8">
<layout xsi:type="FastJsonLayoutToUseIfAllLogEventPropertiesAreImmutable" includeAllProperties="true">
<attribute name="timestamp" layout="${date:format=yyyy-MM-dd HH\:mm\:ss.ffff K}" />
<attribute name="logLevel" layout="${level:upperCase=true}" />
<attribute name="subsystem" layout="${subsystem}" />
<attribute name="application" layout="${appName}" />
<attribute name="applicationVersion" layout="${appVersion}" />
<attribute name="applicationLongVersion" layout="${appLongVersion}" />
<attribute name="machineName" layout="${machinename}" />
<attribute name="logMessage" layout="${message}" />
<attribute name="exception" layout="${exception:format=tostring:maxinnerexceptionlevel=10}" />
</layout>
</target>
</target>
<target name="consoleIfApplicable" xsi:type="FilteringWrapper"
condition="'${environment:DOTNET_RUNNING_IN_CONTAINER}' == 'true'">
<target name="console"
xsi:type="ColoredConsole"
detectConsoleAvailable="true"
layout="${date:format=yyyy-MM-dd HH\:mm\:ss.ffff K} | ${level:upperCase=true} | ${message} | ${exception:format=tostring:maxinnerexceptionlevel=10}">
</target>
</target>
<target name="consoleIfApplicableBug" xsi:type="FilteringWrapper"
condition="'${environment:DOTNET_RUNNING_IN_CONTAINER}' == 'true'">
<target name="stdConsole"
xsi:type="Console"
detectConsoleAvailable="true"
layout="${date:format=yyyy-MM-dd HH\:mm\:ss.ffff K} | ${level:upperCase=true} | ${message} | ${exception:format=tostring:maxinnerexceptionlevel=10}">
</target>
</target>
Thank you. Have created PR #3918 to fix this.
Btw. you should consider changing this:
condition="'${environment:DOTNET_RUNNING_IN_CONTAINER}' == 'true'"
Into this (Adding cached=true):
condition="'${environment:DOTNET_RUNNING_IN_CONTAINER:cached=true}' == 'true'"
@mariusin79 It would be a great help if you could test this pre-release nuget-package to see if it resolves your issue:
https://ci.appveyor.com/project/nlog/nlog/builds/32386722/artifacts
Just download NLog.4.7.0.11601-PR3918.nupkg and put in a local nuget-repository-folder, then you can try it out.
thank you I will test it tomorrow
On Thu, Apr 23, 2020 at 8:13 PM Rolf Kristensen notifications@github.com
wrote:
@mariusin79 https://github.com/mariusin79 It would be a great help if
you could test this pre-release nuget-package to see if it resolves your
issue:https://ci.appveyor.com/project/nlog/nlog/builds/32386722/artifacts
Just download NLog.4.7.0.11601-PR3918.nupkg and put in a local
nuget-repository-folder, then you can try it out.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/NLog/NLog/issues/3917#issuecomment-618562701, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AAI7SRTNMMK3Q6PFBV6Q55LROCAMNANCNFSM4MO4ZIOQ
.
Any update on the test results?
I will have to test on monday
- apr. 2020 kl. 14:10 skrev Rolf Kristensen notifications@github.com:

Any update on the test results?---- Marius Ingjer wrote ----
thank you I will test it tomorrow
On Thu, Apr 23, 2020 at 8:13 PM Rolf Kristensen notifications@github.com
wrote:@mariusin79 https://github.com/mariusin79 It would be a great help if
you could test this pre-release nuget-package to see if it resolves your
issue:https://ci.appveyor.com/project/nlog/nlog/builds/32386722/artifacts
Just download NLog.4.7.0.11601-PR3918.nupkg and put in a local
nuget-repository-folder, then you can try it out.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/NLog/NLog/issues/3917#issuecomment-618562701, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AAI7SRTNMMK3Q6PFBV6Q55LROCAMNANCNFSM4MO4ZIOQ
.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/NLog/NLog/issues/3917#issuecomment-618593746, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACXZ7HABVTBRWW7TCR6GG33ROCFWLANCNFSM4MO4ZIOQ.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
Tested: was finally able to reproduce a string which caused error, downloaded and installed the prerelease package, bug was gone.
@mariusin79 NLog 4.7.1 has now been released.
Most helpful comment
I will have to test on monday