RichTextBoxTarget Class |
Namespace: NLog.Windows.Forms
The RichTextBoxTarget type exposes the following members.
Name | Description | |
---|---|---|
RichTextBoxTarget |
Initializes a new instance of the RichTextBoxTarget class.
|
Name | Description | |
---|---|---|
AllowAccessoryFormCreation |
Gets or sets a value indicating whether to create accessory form if the specified form/control combination was not found during target initialization.
| |
AutoScroll |
Gets or sets a value indicating whether scroll bar will be moved automatically to show most recent log entries.
| |
ControlName |
Gets or sets the Name of RichTextBox to which Nlog will write.
| |
CreatedForm |
Form created (true) or used an existing (false). Set after InitializeTarget. Can be true only if AllowAccessoryFormCreation is set to true (default).
| |
DefaultRowColoringRules |
Gets the default set of row coloring rules which applies when UseDefaultRowColoringRules is set to true.
| |
FormName |
Gets or sets the name of the Form on which the control is located.
If there is no open form of a specified name than NLog will create a new one.
| |
Height |
Gets or sets the initial height of the form with rich text box.
| |
Layout |
Gets or sets the layout used to format log messages.
(Inherited from TargetWithLayout.) | |
MaxLines |
Gets or sets the maximum number of lines the rich text box will store (or 0 to disable this feature).
| |
MessageRetention |
gets or sets the message retention strategy which determines how the target handles messages when there's no control attached, or when switching between controls
| |
Name |
Gets or sets the name of the target.
(Inherited from Target.) | |
RowColoringRules |
Gets the row coloring rules.
| |
ShowMinimized |
Gets or sets a value indicating whether the created form will be initially minimized.
| |
SupportLinks |
If set to true, using "rtb-link" renderer (RichTextBoxLinkLayoutRenderer) would create clickable links in the control.
| |
TargetForm |
Gets or sets the form to log to.
| |
TargetRichTextBox |
Gets or sets the rich text box to log to.
| |
ToolWindow |
Gets or sets a value indicating whether the created window will be a tool window.
| |
UseDefaultRowColoringRules |
Gets or sets a value indicating whether to use default coloring rules.
| |
Width |
Gets or sets the initial width of the form with rich text box.
| |
WordColoringRules |
Gets the word highlighting rules.
|
Name | Description | |
---|---|---|
Dispose |
Closes the target.
(Inherited from Target.) | |
Flush |
Flush any pending log messages (in case of asynchronous targets).
(Inherited from Target.) | |
GetTargetByControl(RichTextBox) |
Returns a target attached to a given RichTextBox control
| |
GetTargetByControl(RichTextBox, LoggingConfiguration) |
Returns a target attached to a given RichTextBox control
| |
PrecalculateVolatileLayouts |
Calls the Precalculate(LogEventInfo) on each volatile layout
used by this target.
This method won't prerender if all layouts in this target are thread-agnostic.
(Inherited from Target.) | |
ReInitializeAllTextboxes(Form) |
Attempts to attach existing targets that have yet no textboxes to controls that exist on specified form if appropriate
| |
ReInitializeAllTextboxes(Form, LoggingConfiguration) |
Attempts to attach existing targets that have yet no textboxes to controls that exist on specified form if appropriate
| |
ToString | Returns a string that represents the current object. (Inherited from Target.) | |
WriteAsyncLogEvent |
Writes the log to the target.
(Inherited from Target.) | |
WriteAsyncLogEvents(AsyncLogEventInfo) |
Writes the array of log events.
(Inherited from Target.) | |
WriteAsyncLogEvents(IListAsyncLogEventInfo) |
Writes the array of log events.
(Inherited from Target.) |
Name | Description | |
---|---|---|
LinkClicked |
Event fired when the user clicks on a link in the control created by the "rtb-link" renderer (RichTextBoxLinkLayoutRenderer).
|
To set up the target in the configuration file, use the following syntax:
1<?xml version="1.0" encoding="utf-8" ?> 2<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4 5 <targets> 6 <target name="richTextBox" xsi:type="RichTextBox" controlName="richTextBox1" formName="form1" useDefaultRowColoringRules="false"/> 7 </targets> 8 9 <rules> 10 <logger name="*" minlevel="Debug" writeTo="richTextBox" /> 11 </rules> 12</nlog>
The result is:
To set up the target with coloring rules in the configuration file, use the following syntax:
1<?xml version="1.0" encoding="utf-8" ?> 2<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4 5 <targets> 6 <target name="richTextBox" xsi:type="RichTextBox" controlName="richTextBox1" formName="form1" useDefaultRowColoringRules="true"> 7 <row-coloring condition="contains(message,'serious')" fontColor="Red" backgroundColor="Blue" style="Underline,Italic" /> 8 </target> 9 </targets> 10 11 <rules> 12 <logger name="*" minlevel="Debug" writeTo="richTextBox" /> 13 </rules> 14</nlog>
1<?xml version="1.0" encoding="utf-8" ?> 2<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4 5 <targets> 6 <target name="richTextBox" xsi:type="RichTextBox" controlName="richTextBox1" formName="form1" useDefaultRowColoringRules="true"> 7 <word-coloring text="message" fontColor="Green" backgroundColor="Black"/> 8 </target> 9 </targets> 10 11 <rules> 12 <logger name="*" minlevel="Debug" writeTo="richTextBox" /> 13 </rules> 14</nlog>
The result is:
To set up the log target programmatically similar to above use code like this:
1!ERROR: See log file!
1!ERROR: See log file!
1!ERROR: See log file!