This documentation is archived and is not being maintained.

LogStore Class

Represents a log-structured storage.


Namespace:  System.IO.Log
Assembly:  System.IO.Log (in System.IO.Log.dll)

public sealed class LogStore : IDisposable

The LogStore type exposes the following members.

Public methodLogStore(SafeFileHandle)Initializes a new instance of the LogStore class for the specified handle.
Public methodLogStore(String, FileMode)Initializes a new instance of the LogStore class with the specified path and mode.
Public methodLogStore(String, FileMode, FileAccess)Initializes a new instance of the LogStore class with the specified path, mode, and access.
Public methodLogStore(String, FileMode, FileAccess, FileShare)Initializes a new instance of the LogStore class.
Public methodLogStore(String, FileMode, FileAccess, FileShare, FileSecurity)Initializes a new instance of the LogStore class.

Public propertyArchivableGets a value indicating whether this LogStore instance can be archived.
Public propertyBaseSequenceNumberGets the lowest sequence number that corresponds to a valid record in this LogStore instance.
Public propertyExtentsGets the collection of log extents that contain the data for this log store.
Public propertyFreeBytesGets the number of bytes available in the log store.
Public propertyHandleGets the operating system file handle for the log file that the current LogStore instance encapsulates.
Public propertyLastSequenceNumberWhen overridden in a derived class, gets the sequence number of the next record to be appended to the log store.
Public propertyLengthGets the size of the log store, in bytes.
Public propertyPolicyGets the policy associated with this log store.
Public propertyStreamCountGets the number of log streams in this log store.

Public methodCreateLogArchiveSnapshot()Takes a snapshot of the log store state for making a backup.
Public methodCreateLogArchiveSnapshot(SequenceNumber, SequenceNumber)Takes a snapshot of the log store state between the specified sequence numbers for making a backup.
Public methodStatic memberDeleteRemoves the log store.
Public methodDisposeReleases all resources used by the LogStore.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSetArchiveTailSets the sequence number of the archive tail.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

The LogRecordSequence class provides an implementation of the record sequence interface on top of a Common Log File System (CLFS) log. It works with the LogStore class, which provides an interface for directly manipulating and managing a CLFS log file. A log store provides append-only storage across a set of disk extents. The LogStore class represents this storage, and provides methods for adding and removing containers, setting policy, and creating archives. It does not provide methods for reading from and writing to the storage; these methods are provided by the LogRecordSequence class.

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 actual storage and has attributes such as length and last access time, while 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 like a policy and a collection of disk extents, and the LogRecordSequence class provides a record-oriented mechanism for reading and writing data.

Unlike the file record sequence represented by the FileRecordSequence class, 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. To add and remove log extents, use the Add and Remove methods of the LogExtentCollection object, which can be returned by the Extents property.

A LogStore instance can have policies associated with it. These are represented by LogPolicy instances that can be returned by the Policy property. 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 specify whether a LogStore instance can be archived. Policies are set per log and are volatile, which means that once every handle to the log is closed, the policy no longer exists.

The following example shows how to archive a LogStore to an XML document.

class LogBackup
    static void ArchiveToXML(LogStore logStore, string fileName) 
        LogArchiveSnapshot snapshot = logStore.CreateLogArchiveSnapshot();

        XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.ASCII);

        foreach(FileRegion region in snapshot.ArchiveRegions) 
            writer.WriteElementString("path", region.Path); 
            writer.WriteElementString("length", region.FileLength.ToString()); 
            writer.WriteElementString("offset", region.Offset.ToString()); 
            using(Stream dataStream = region.GetStream()) 
                byte[] data = new byte[dataStream.Length]; 
                dataStream.Read(data, 0, data.Length); 
                writer.WriteElementString("data", Convert.ToBase64String(data)); 

    static void RestoreFromXML(string fileName) 
        using(XmlTextReader reader = new XmlTextReader(fileName)) 
                string path = reader.ReadElementString("path"); 
                long length = Int64.Parse(reader.ReadElementString("length")); 
                long offset = Int64.Parse(reader.ReadElementString("offset")); 
                string dataString = reader.ReadElementString("data"); 
                byte[] data = Convert.FromBase64String(dataString); 
                FileStream fileStream;
                using(fileStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write)) 
                    fileStream.Position = offset; fileStream.Write(data, 0, data.Length); 

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.