Compartilhar via


TraceSwitch.TraceInfo Propriedade

Definição

Obtém um valor que indica se a opção permite mensagens informativas.

public:
 property bool TraceInfo { bool get(); };
public bool TraceInfo { get; }
member this.TraceInfo : bool
Public ReadOnly Property TraceInfo As Boolean

Valor da propriedade

true se a Level propriedade estiver definida Info como ou Verbose; caso contrário, false.

Exemplos

O exemplo de código a seguir cria um novo TraceSwitch e usa a opção para determinar se as mensagens de erro devem ser emitidas. A opção é criada no nível da classe. MyMethod grava a primeira mensagem de erro se a Level propriedade estiver definida como TraceLevel.Info ou superior. No entanto, MyMethod não gravará a segunda mensagem de erro se for Level menor que TraceLevel.Verbose.

//Class-level declaration.
/* Create a TraceSwitch to use in the entire application.*/
static TraceSwitch mySwitch = new TraceSwitch("General", "Entire Application");

static public void MyMethod()
{
    // Write the message if the TraceSwitch level is set to Info or higher.
    if (mySwitch.TraceInfo)
        Console.WriteLine("My error message.");

    // Write the message if the TraceSwitch level is set to Verbose.
    if (mySwitch.TraceVerbose)
        Console.WriteLine("My second error message.");
}

public static void Main(string[] args)
{
    // Run the method that prints error messages based on the switch level.
    MyMethod();
}
' Class-level declaration.
' Create a TraceSwitch to use in the entire application. 
Private Shared mySwitch As New TraceSwitch("General", "Entire Application")
   
Public Shared Sub MyMethod()
    ' Write the message if the TraceSwitch level is set to Info or higher.
    If mySwitch.TraceInfo Then
        Console.WriteLine("My error message.")
    End If 
    ' Write the message if the TraceSwitch level is set to Verbose.
    If mySwitch.TraceVerbose Then
        Console.WriteLine("My second error message.")
    End If
End Sub

Public Shared Sub Main()
    ' Run the method that prints error messages based on the switch level.
    MyMethod()
End Sub

Comentários

Você pode usar as TraceErrorpropriedades , TraceWarninge TraceInfoTraceVerbose , em conjunto com as Debug classes e Trace para emitir todas as mensagens com uma importância especificada ou maior. Quando a Level propriedade é definida como TraceLevel.Warning, mensagens informativas, avisos e mensagens de tratamento de erros são emitidos.

Aplica-se a

Confira também