LogPolicy Class

LogPolicy Class

 

Represents the policy associated with a LogStore.

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

System.Object
  System.IO.Log.LogPolicy

public sealed class LogPolicy

NameDescription
System_CAPS_pubpropertyAutoGrow

Gets or sets a value indicating whether the LogStore can grow automatically.

System_CAPS_pubpropertyAutoShrinkPercentage

Gets or sets the percentage of free space the LogStore can shrink.

System_CAPS_pubpropertyGrowthRate

Gets or sets the rate of automatic growth of the LogStore.

System_CAPS_pubpropertyMaximumExtentCount

Gets or sets the maximum number of LogExtent instances the LogStore can contain.

System_CAPS_pubpropertyMinimumExtentCount

Gets or sets the minimum number of LogExtent instances the LogStore can contain.

System_CAPS_pubpropertyNewExtentPrefix

Gets or sets the prefix string for automatically created extents.

System_CAPS_pubpropertyNextExtentSuffix

Gets or sets the suffix number for new extents.

System_CAPS_pubpropertyPinnedTailThreshold

Gets or sets the amount of space that the TailPinned event requires for advancing the base of the log.

NameDescription
System_CAPS_pubmethodCommit()

Sets this policy as the current policy for the LogStore.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodRefresh()

Reads the current policy for the LogStore, discarding any changes that may have been made.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

A policy is a set of rules to be followed by a LogStore instance and its clients. A LogPolicy instance is used to examine and modify the policy associated with a specific LogStore. A policy can describe the minimum and maximum allowable log sizes, or how the LogStore instance is allowed to grow. In addition, you can also control whether a LogStore instance can be archived.

After changing any of the properties, you should use the Commit method to ensure that the changes are applied to the LogStore. You can call the Refresh method to discard changes or to get the most current policy.

This example shows how to use the LogPolicy class to set policy for a log record sequence.

// SET LOG POLICY

LogPolicy policy = sequence.LogStore.Policy;

// Set AutoGrow policy. This enables the log to automatically grow
// when the existing extents are full. New extents are added until
// we reach the MaximumExtentCount extents.
// AutoGrow policy is supported only in Windows Vista and not available in R2.

//policy.AutoGrow = true;

// Set the Growth Rate in terms of extents. This policy specifies
// "how much" the log should grow. 
policy.GrowthRate = new PolicyUnit(2, PolicyUnitType.Extents);

// Set the AutoShrink policy. This enables the log to automatically
// shrink if the available free space exceeds the shrink percentage. 
// AutoGrow/shrink policy is supported only in Windows Vista and not available in R2.

//policy.AutoShrinkPercentage = new PolicyUnit(30, PolicyUnitType.Percentage);

// Set the PinnedTailThreshold policy.
// A tail pinned event is triggered when there is no
// log space available and log space may be freed by advancing the base.
// The user must handle the tail pinned event by advancing the base of the log. 
// If the user is not able to move the base of the log, the user should report with exception in
// the tail pinned handler.
// PinnedTailThreashold policy dictates the amount of space that the TailPinned event requests 
// for advancing the base of the log. The amount of space can be in percentage or in terms of bytes 
// which is rounded off to the nearest containers in CLFS. The default is 35 percent.


policy.PinnedTailThreshold = new PolicyUnit(10, PolicyUnitType.Percentage);

// Set the maximum extents the log can have.
policy.MaximumExtentCount = 6;

// Set the minimum extents the log can have.
policy.MinimumExtentCount = 2;

// Set the prefix for new containers that are added. 
// when AutoGrow is enabled.
//policy.NewExtentPrefix = "MyLogPrefix";

// Set the suffix number for new containers that are added.
// when AutoGrow is enabled. 
policy.NextExtentSuffix = 3;

// Commit the log policy.
policy.Commit();

// Refresh updates the IO.Log policy properties with current log policy 
// set in the log. 
policy.Refresh();

// LOG POLICY END
// 

.NET Framework
Available since 3.0

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

Return to top
Show:
© 2016 Microsoft