FileLogTraceListener.Append Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Determines whether to append the output to the current file or write it to a new or existing file.
public:
property bool Append { bool get(); void set(bool value); };
public bool Append { get; set; }
member this.Append : bool with get, set
Public Property Append As Boolean
Property Value
Boolean
, with True
indicating that the output is appended to the current file, and False
indicating that output is written to a new file. The default setting for this property is True
.
Remarks
When the Append property is True
, the log file is opened in Append mode, to keep existing logs. The current writing position starts at the end of the file, so that any new logs are appended to the end of the file.
When the Append
property is False
, the log file is opened in Truncate mode, where all log data is deleted when the log file is opened. The FileLogTraceListener
deletes existing contents of the log file once after the Append
propery is set to False
or the file is opened and before it writes the first log. After that, FileLogTraceListener
appends additional trace data to the end of the file. If the FileLogTraceListener
instance is closed and then reopened while Append is set to False, it erases the log file data before writing additional logs. This can lead to missing data, particularly if you set the value of the Append
property to False
in a configuration file.
This behavior is overridden in the following scenarios:
The output file is locked by another process. A new log file is created with a version number that is incorporated into the FullLogFileName name.
The current file size is greater than what the MaxFileSize property allows. Additional messages are discarded. Depending on the DiskSpaceExhaustedBehavior property, an exception is thrown.
The existing file name is out of date according to the log-creation schedule specified by the LogFileCreationSchedule property. A new log file is created. The date stamp is incorporated into the FullLogFileName name.