TraceSwitch.TraceInfo 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
스위치에서 정보 메시지를 허용하는지 여부를 나타내는 값을 가져옵니다.
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되면 정보 메시지, 경고 및 오류 처리 메시지가 내보내집니다.
적용 대상
추가 정보
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기