TraceSwitch.TraceInfo 속성

정의

스위치에서 정보 메시지를 허용하는지 여부를 나타내는 값을 가져옵니다.

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

속성 값

Level 속성이 Info 또는 Verbose로 설정되어 있으면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는 새 TraceSwitch 를 만들고 스위치를 사용하여 오류 메시지를 내보냅니다. 스위치는 클래스 수준에서 생성 됩니다. MyMethod속성이 이상으로 설정된 TraceLevel.Info 경우 Level 첫 번째 오류 메시지를 씁니다. 그러나 가 MyMethod 보다 TraceLevel.Verbose작으면 Level 두 번째 오류 메시지를 작성하지 않습니다.

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

public:
   static 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." );
   }

   static void main()
   {
      // 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.*/
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

설명

, , 및 속성을 및 Trace 클래스와 TraceVerbose 함께 Debug 사용하여 TraceError지정된 중요도 이상의 모든 메시지를 내보낼 수 있습니다. TraceInfoTraceWarning 속성이 Level 로 설정 TraceLevel.Warning되면 정보 메시지, 경고 및 오류 처리 메시지가 내보내집니다.

적용 대상

추가 정보