RichTextBox target - NLog/NLog GitHub Wiki
Log text a Rich Text Box control in an existing or new form.
Platforms Supported: .NetFramework + NETCore3.1 + NET6.0 - Requires nuget-package NLog.Windows.Forms
<targets>
<target xsi:type="RichTextBox"
name="String"
layout="Layout"
height="Integer"
autoScroll="Boolean"
maxLines="Integer"
showMinimized="Boolean"
toolWindow="Boolean"
controlName="String"
formName="String"
width="Integer"
useDefaultRowColoringRules="Boolean">
<word-coloring backgroundColor="String" fontColor="String" ignoreCase="Boolean"
regex="String" style="Enum" text="String"
wholeWords="Boolean"/><!-- repeated -->
<row-coloring backgroundColor="String" condition="Condition" fontColor="String"
style="Enum"/><!-- repeated -->
</target>
</targets>
Read more about using the Configuration File.
- name - Name of the target.
-
layout - Layout used to format log messages. Required. Default:
${longdate}|${level:uppercase=true}|${logger}|${message:withexception=true}
-
height - Initial height of the form with rich text box.
This parameter is ignored when logging to existing form control.
-
autoScroll - Indicates whether scroll bar will be moved automatically to show most recent log entries.
-
maxLines - Maximum number of lines the rich text box will store (or 0 to disable this feature).
After exceeding the maximum number, first line will be deleted.
-
showMinimized - Indicates whether the created form will be initially minimized.
This parameter is ignored when logging to existing form control.
-
toolWindow - Indicates whether the created window will be a tool window. Default: True
This parameter is ignored when logging to existing form control. Tool windows have thin border, and do not show up in the task bar.
-
controlName - Name of RichTextBox to which Nlog will write.
-
formName - Name of the Form on which the control is located. If there is no open form of a specified name then NLog will create a new one.
-
width - Initial width of the form with rich text box.
This parameter is ignored when logging to existing form control.
-
wordColoringRules - The word highlighting rules. Collection
Each collection item is represented by <word-coloring /> element with the following attributes:- backgroundColor - Background color. Names are identical with KnownColor enum extended with Empty value which means that background color won't be changed. Default: Empty
- fontColor - Font color. Names are identical with KnownColor enum extended with Empty value which means that font color won't be changed. Default: Empty
- ignoreCase - Indicates whether to ignore case when comparing texts. Boolean Default: False
- regex - Regular expression to be matched. You must specify either text or regex.
-
style - Font style of matched text. Possible values are the same as in FontStyle enum in System.Drawing.
Possible values:
- Bold -
- Italic -
- Regular -
- Strikeout -
- Underline -
-
text - Text to be matched. You must specify either text or regex.
-
wholeWords - Indicates whether to match whole words only. Boolean Default: False
-
useDefaultRowColoringRules - Indicates whether to use default coloring rules.Boolean Default: False
-
rowColoringRules - The row coloring rules. Collection
Each collection item is represented by <row-coloring /> element with the following attributes:- backgroundColor - Background color. Names are identical with KnownColor enum extended with Empty value which means that background color won't be changed. Default: Empty
- fontColor - Font color. Names are identical with KnownColor enum extended with Empty value which means that font color won't be changed. Default: Empty
- ignoreCase - Indicates whether to ignore case when comparing texts. Boolean Default: False
- regex - Regular expression to be matched. You must specify either text or regex.
-
style - Font style of matched text. Possible values are the same as in FontStyle enum in System.Drawing.
Possible values:- Bold -
- Italic -
- Regular -
- Strikeout -
- Underline - Possible values are the same as in FontStyle enum in System.Drawing