Ler em inglês

Compartilhar via


LogPolicy Classe

Definição

Representa a política associada a um LogStore.

C#
public sealed class LogPolicy
Herança
LogPolicy

Exemplos

Este exemplo mostra como usar a LogPolicy classe para definir a política para uma sequência de registro de log.

C#
// 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
//

Comentários

Uma política é um conjunto de regras a serem seguidas por uma LogStore instância e seus clientes. Uma LogPolicy instância é usada para examinar e modificar a política associada a um específico LogStore. Uma política pode descrever os tamanhos de log permitidos mínimos e máximos ou como a LogStore instância tem permissão para crescer. Além disso, você também pode controlar se uma LogStore instância pode ser arquivada.

Depois de alterar qualquer uma das propriedades, você deve usar o Commit método para garantir que as alterações sejam aplicadas ao LogStore. Você pode chamar o Refresh método para descartar alterações ou para obter a política mais atual.

Propriedades

AutoGrow

Obtém ou define um valor que indica se o LogStore pode crescer automaticamente.

AutoShrinkPercentage

Obtém ou define o percentual de espaço livre que o LogStore pode reduzir.

GrowthRate

Obtém ou define a taxa de crescimento automático do LogStore.

MaximumExtentCount

Obtém ou define o número máximo de instâncias LogExtent que LogStore pode conter.

MinimumExtentCount

Obtém ou define o número mínimo de instâncias LogExtent que LogStore pode conter.

NewExtentPrefix

Obtém ou define a cadeia de caracteres de prefixo para extensões criadas automaticamente.

NextExtentSuffix

Obtém ou define o número de sufixo de novas extensões.

PinnedTailThreshold

Obtém ou define a quantidade de espaço que o evento TailPinned requer para avançar a base do log.

Métodos

Commit()

Define essa política como a política atual para o LogStore.

Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.

(Herdado de Object)
GetHashCode()

Serve como a função de hash padrão.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do Object atual.

(Herdado de Object)
Refresh()

Lê a política atual para o LogStore, descartando todas as alterações que talvez tenham sido feitas.

ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.

(Herdado de Object)

Aplica-se a

Produto Versões
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1