Export (0) Print
Expand All
This topic has not yet been rated - 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.

Note

The default location of system.io.log.dll is %programfiles%\Reference Assemblies\Microsoft\Framework\v3.0\

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 classFileRecordSequenceImplements an IRecordSequence on top of a file. This class cannot be inherited.
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 classLogExtentCollectionRepresents the collection of LogExtent objects associated with a LogStore.
Public classLogPolicyRepresents the policy associated with a LogStore.
Public classLogRecordRepresents a log record that has been appended to a sequence.
Public classLogRecordSequenceRepresents a record sequence stored in a LogStore.
Public classLogStoreRepresents a log-structured storage.
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 classSequenceFullExceptionRepresents the exception that is thrown when a sequence of log records is full.
Public classTailPinnedEventArgsProvides data for the TailPinned event. This class cannot be inherited.
  StructureDescription
Public structurePolicyUnitRepresents a size measurement in a log store policy.
Public structureSequenceNumberRepresents a sequence number assigned to a log record in a record sequence.
  InterfaceDescription
Public interfaceIRecordSequenceProvides a generic interface to a sequence of records.
  EnumerationDescription
Public enumerationLogExtentStateDescribes the current state of a LogExtent instance.
Public enumerationLogRecordEnumeratorTypeSpecifies the manner in which records should be read from a LogRecordSequence.
Public enumerationPolicyUnitTypeSpecifies the unit of measurement of a PolicyUnit instance.
Public enumerationRecordAppendOptionsSpecifies how records are appended.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.