Table of Contents

Class RollingFlatFileTraceListener.StreamWriterRollingHelper

Namespace
Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners
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 RollingFlatFileTraceListener

The 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 DateTime

The 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

DateTime?

The date roll to use if performing a roll, or null if no rolling should occur.

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

actualFileName string

The actual file name.

currentDateTime DateTime

The current date and time.

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 string

The directory to scan.

fileName string

The file name.

extension string

The 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 DateTime

The 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.