Class RollingFlatFileTraceListener
- Assembly
- Microsoft.Practices.EnterpriseLibrary.Logging.dll
Performs logging to a file and rolls the output file when either time or size thresholds are exceeded.
public class RollingFlatFileTraceListener : FlatFileTraceListener, IDisposable
- Inheritance
-
RollingFlatFileTraceListener
- Implements
- Inherited Members
Remarks
Logging always occurs to the configured file name, and when roll occurs a new rolled file name is calculated by adding the timestamp pattern to the configured file name.
The need of rolling is calculated before performing a logging operation, so even if the thresholds are exceeded roll will not occur until a new entry is logged. Both time and size thresholds can be configured, and when the first threshold is reached, both will be reset. The elapsed time is calculated from the creation date of the logging file.Constructors
RollingFlatFileTraceListener(string, string, string, ILogFormatter, int, string, RollFileExistsBehavior, RollInterval, int)
Initializes a new instance of the RollingFlatFileTraceListener class.
public RollingFlatFileTraceListener(string fileName, string header = "----------------------------------------", string footer = "----------------------------------------", ILogFormatter formatter = null, int rollSizeKB = 0, string timeStampPattern = "yyyy-MM-dd", RollFileExistsBehavior rollFileExistsBehavior = RollFileExistsBehavior.Overwrite, RollInterval rollInterval = RollInterval.None, int maxArchivedFiles = 0)
Parameters
fileName
stringThe filename where the entries will be logged.
header
stringThe header to add before logging an entry.
footer
stringThe footer to add after logging an entry.
formatter
ILogFormatterThe formatter.
rollSizeKB
intThe maxium file size (KB) before rolling.
timeStampPattern
stringThe date format that will be appended to the new roll file.
rollFileExistsBehavior
RollFileExistsBehaviorExpected behavior that will be used when the roll file has to be created.
rollInterval
RollIntervalThe time interval that makes the file rolles.
maxArchivedFiles
intThe maximum number of archived files to keep.
Fields
DefaultSeparator
Represents the default separator used for headers and footers.
public const string DefaultSeparator = "----------------------------------------"
Field Value
Properties
RollingHelper
Gets the RollingFlatFileTraceListener.StreamWriterRollingHelper for the flat file.
public RollingFlatFileTraceListener.StreamWriterRollingHelper RollingHelper { get; }
Property Value
- RollingFlatFileTraceListener.StreamWriterRollingHelper
The RollingFlatFileTraceListener.StreamWriterRollingHelper for the flat file.
Methods
Dispose(bool)
Releases managed resources.
protected override void Dispose(bool disposing)
Parameters
disposing
booltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
~RollingFlatFileTraceListener()
Finalizes an instance of the RollingFlatFileTraceListener class.
protected ~RollingFlatFileTraceListener()
TraceData(TraceEventCache, string, TraceEventType, int, object)
Writes trace information, a data object and event information to the file, performing a roll if necessary.
public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
Parameters
eventCache
TraceEventCacheA TraceEventCache object that contains the current process ID, thread ID, and stack trace information.
source
stringA name used to identify the output, typically the name of the application that generated the trace event.
eventType
TraceEventTypeOne of the TraceEventType values specifying the type of event that has caused the trace.
id
intA numeric identifier for the event.
data
objectThe trace data to emit.