-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
NLog version: 6.0
Platform: .NET8
Current NLog config (xml or C#, if relevant)
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwConfigExceptions="false"
internalLogLevel="Trace"
internalLogFile="${basedir}/logs/internal-nlog.txt">
<targets>
<target xsi:type="RichTextBox"
name="EventToRichTextFieldGUI"
layout="${longdate} | ${uppercase:${level}} | ${message:withexception=false}"
controlName="LogTextBox"
formName="Form1"
autoScroll="true"
maxLines="1000"
useDefaultRowColoringRules="True"/>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="EventToRichTextFieldGUI"/>
</rules>
</nlog>-
What is the current result?
NLog fails to write to RichTextBox with DefaultRowColoringRules -
What is the expected result?
Default colored text in my RichTextBox -
Did you checked the Internal log?
yes. -
Please post full exception details (message, stacktrace, inner exceptions)
Warn RichTextBoxTarget(Name=EventToRichTextFieldGUI): Exception in Write Exception: System.TypeInitializationException: The type initializer for 'NLog.Windows.Forms.RichTextBoxTarget' threw an exception.
---> System.TypeInitializationException: The type initializer for 'NLog.Windows.Forms.RichTextBoxRowColoringRule' threw an exception.
---> System.ArgumentNullException: Value cannot be null. (Parameter 'expressionText')
at NLog.Internal.Guard.ThrowIfNull[T](T arg, String param)
at NLog.Conditions.ConditionParser.ParseExpression(String expressionText)
at NLog.Conditions.ConditionExpression.op_Implicit(String conditionExpressionText)
at NLog.Windows.Forms.RichTextBoxRowColoringRule..ctor(String condition, String fontColor, String backColor, FontStyle fontStyle)
at NLog.Windows.Forms.RichTextBoxRowColoringRule..ctor()
at NLog.Windows.Forms.RichTextBoxRowColoringRule..cctor()
--- End of inner exception stack trace ---
at NLog.Windows.Forms.RichTextBoxRowColoringRule..ctor(String condition, String fontColor, String backColor, FontStyle fontStyle)
at NLog.Windows.Forms.RichTextBoxTarget.CreateDefaultColoringRules()
at NLog.Windows.Forms.RichTextBoxTarget..cctor()
--- End of inner exception stack trace ---
at NLog.Windows.Forms.RichTextBoxTarget.get_DefaultRowColoringRules()
at NLog.Windows.Forms.RichTextBoxTarget.FindMatchingRule(LogEventInfo logEvent)
at NLog.Windows.Forms.RichTextBoxTarget.Write(LogEventInfo logEvent)
at NLog.Targets.Target.Write(AsyncLogEventInfo logEvent)
-
Are there any workarounds? yes/no
I dont know. Maybe providing custom coloring rules. -
Is there a version in which it did work?
yes, NLog <=5.5.0 -
Can you help us by writing an unit test?