Class RollingFlatFileTraceListener.StreamWriterRollingHelper
- Assembly
- Microsoft.Practices.EnterpriseLibrary.Logging.dll
Encapsulates the logic to perform rolls.
public sealed class RollingFlatFileTraceListener.StreamWriterRollingHelper
- Inheritance
-
RollingFlatFileTraceListener.StreamWriterRollingHelper
- Inherited Members
Remarks
If no rolling behavior has been configured no further processing will be performed.
Constructors
StreamWriterRollingHelper(RollingFlatFileTraceListener)
Initializes a new instance of the RollingFlatFileTraceListener.StreamWriterRollingHelper.
public StreamWriterRollingHelper(RollingFlatFileTraceListener owner)
Parameters
owner
RollingFlatFileTraceListenerThe RollingFlatFileTraceListener to use.
Properties
DateTimeProvider
Gets the provider for the current date. Necessary for unit testing.
public RollingFlatFileTraceListener.DateTimeProvider DateTimeProvider { set; }
Property Value
- RollingFlatFileTraceListener.DateTimeProvider
The provider for the current date. Necessary for unit testing.
NextRollDateTime
Gets the next date when date based rolling should occur if configured.
public DateTime? NextRollDateTime { get; }
Property Value
- DateTime?
The next date when date based rolling should occur if configured.
Methods
CalculateNextRollDate(DateTime)
Calculates the next roll date for the file.
public DateTime CalculateNextRollDate(DateTime dateTime)
Parameters
dateTime
DateTimeThe new date.
Returns
- DateTime
The new date time to use.
CheckIsRollNecessary()
Checks whether rolling should be performed, and returns the date to use when performing the roll.
public DateTime? CheckIsRollNecessary()
Returns
Remarks
Defer request for the roll date until it is necessary to avoid overhead.
Information used for rolling checks should be set by now.ComputeArchiveFileName(string, DateTime)
Gets the file name to use for archiving the file.
public string ComputeArchiveFileName(string actualFileName, DateTime currentDateTime)
Parameters
Returns
- string
The new file name.
FindMaxSequenceNumber(string, string, string)
Finds the max sequence number for a log file.
public static int FindMaxSequenceNumber(string directoryName, string fileName, string extension)
Parameters
directoryName
stringThe directory to scan.
fileName
stringThe file name.
extension
stringThe extension to use.
Returns
- int
The next sequence number.
PerformRoll(DateTime)
Perform the roll for the next date.
public void PerformRoll(DateTime rollDateTime)
Parameters
rollDateTime
DateTimeThe roll date.
RollIfNecessary()
Rolls the file if necessary.
public void RollIfNecessary()
UpdateRollingInformationIfNecessary()
Updates book keeping information necessary for rolling, as required by the specified rolling configuration.
public bool UpdateRollingInformationIfNecessary()
Returns
- bool
true if update was successful, false if an error occurred.