FormControlTarget Class |
Namespace: NLog.Windows.Forms
The FormControlTarget type exposes the following members.
Name | Description | |
---|---|---|
FormControlTarget |
Initializes a new instance of the FormControlTarget class.
|
Name | Description | |
---|---|---|
Append |
Gets or sets a value indicating whether log text should be appended to the text of the control instead of overwriting it. | |
ControlName |
Gets or sets the name of control to which NLog will log write log text.
| |
FormName |
Gets or sets the name of the Form on which the control is located.
| |
Layout |
Gets or sets the layout used to format log messages.
(Inherited from TargetWithLayout.) | |
Name |
Gets or sets the name of the target.
(Inherited from Target.) | |
ReverseOrder |
Gets or sets whether new log entry are added to the start or the end of the control
|
Name | Description | |
---|---|---|
Dispose |
Closes the target.
(Inherited from Target.) | |
Flush |
Flush any pending log messages (in case of asynchronous targets).
(Inherited from Target.) | |
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.) | |
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.) |
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="control" xsi:type="FormControl" append="true" controlName="textBox1" formName="Form1" /> 7 </targets> 8 9 <rules> 10 <logger name="*" minlevel="Debug" writeTo="control" /> 11 </rules> 12</nlog>
The result is:
To set up the log target programmatically similar to above use code like this:
1!ERROR: See log file!