Export (0) Print
Expand All
2 out of 2 rated this helpful - Rate this topic

System.IO.Log Namespace

The System.IO.Log namespace defines an interface for logging to a record-oriented sequential I/O system. Using the classes from this namespace, you can implement your own diagnostic logging or transaction processing system. The namepsace also provides an implementation of this interface that uses a simple file-based log and an alternative implementation that uses the Common Log File System (CLFS) provided by ws2003r2 and Windows Vista.

Implementations of the IRecordSequence interface can be used to read and write log records. When log records are appended to an implementation of the IRecordSequence interface, each one is given a unique sequence number. Sequence numbers are strictly monotonically increasing within a given record sequence. Sequence numbers from different record sequences are not comparable.

Two different implementations of this interface are provided by the FileRecordSequence and LogRecordSequence classes. The FileRecordSequence is a record sequence based on a single log file in the file system.

The LogRecordSequence class, on the other hand, provides an implementation of the record sequence interface on top of a Common Log File System (CLFS) log. In addition to the standard record-oriented features, it provides a policy model for avoiding log-full conditions, and multiplexing of clients on the same physical file. This class works with the LogStore class which provides an interface for directly manipulating and managing a CLFS log file. The relationship between the LogStore class and the LogRecordSequence class is similar to the relationship between a disk file and a FileStream object. The disk file provides the concrete storage, and has attributes such as length and last access time; the FileStream object provides a view on the file that can be used to read from it and write to it. Similarly, the LogStore class has attributes such as a policy and a collection of disk extents; the LogRecordSequence class provides a record-oriented mechanism for reading and writing data.

Unlike the file record sequence, a LogStore instance stores its data in a collection of disk extents, represented by LogExtent instances. The extents in a given LogStore instance are all of uniform size, and space is added to and removed from a LogStore instance in extent increments.

A LogStore instance can have policy associated with it, represented a LogPolicy instance. A policy dictates rules that the log will attempt to follow, such as maximum number of extents and minimum size, and instructions on growing or shrinking the LogStore under certain conditions. In addition, you can also control whether a LogStore instance is archivable or non-archivable.

Archivable logs have an “archive tail”, which is the lowest sequence number of data that has not been archived. In order to move the archive tail, you should:

  1. Create a LogArchiveSnapshot that represents a snapshot of the data that must be archived together in order to have a consistent backup of the log.

  2. Archive the data from the LogArchiveSnapshot.

  3. Call SetArchiveTail with the last sequence number that was archived.

Caution noteCaution:

Applications which use System.IO.Log must be prepared to handle failfasts resulting from the infrastructure. In some scenarios, System.IO.Log does not use exceptions to communicate errors to an application. Instead, exceptions are used primarily for recoverable errors by which an application developer can act upon. However, failfasts will occur when further execution would result in corrupted or potentially unusable log files. When failfasts occur, no other application action is available to rectify the problem, and an application must be prepared to terminate. For more information on failfast, see FailFast.

 ClassDescription
Public classFileRecordSequence 
Public classFileRegionRepresents a region of a file to be archived. This class cannot be inherited.
Public classLogArchiveSnapshotRepresents a snapshot of the LogStore instance that can be used to generate an archive.
Public classLogExtentRepresents a disk extent that contains log data.
Public classLogExtentCollection 
Public classLogPolicy 
Public classLogRecordRepresents a log record that has been appended to a sequence.
Public classLogRecordSequence 
Public classLogStore 
Public classReservationCollectionManages the collection of space reservations made in a record sequence.
Public classReservationNotFoundExceptionRepresents the exception that is thrown when a specific space reservation in a LogRecordSequence is not found.
Public classSequenceFullException 
Public classTailPinnedEventArgs 
 InterfaceDescription
Public interfaceIRecordSequence 
 StructureDescription
Public structurePolicyUnit 
Public structureSequenceNumber 
 EnumerationDescription
Public enumerationLogExtentState 
Public enumerationLogRecordEnumeratorTypeSpecifies the manner in which records should be read from a LogRecordSequence.
Public enumerationPolicyUnitType 
Public enumerationRecordAppendOptionsSpecifies how records are appended.

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.