Trace.Write 메서드

정의

Listeners 컬렉션의 추적 수신기에 추적에 대한 정보를 씁니다.

오버로드

Write(Object)

ToString() 컬렉션의 추적 수신기에 개체의 Listeners 메서드 값을 씁니다.

Write(String)

Listeners 컬렉션의 추적 수신기에 메시지를 씁니다.

Write(Object, String)

ToString() 컬렉션의 추적 수신기에 범주 이름 및 개체의 Listeners 메서드 값을 씁니다.

Write(String, String)

Listeners 컬렉션의 추적 수신기에 범주 이름 및 메시지를 씁니다.

Write(Object)

Source:
Trace.cs
Source:
Trace.cs
Source:
Trace.cs

ToString() 컬렉션의 추적 수신기에 개체의 Listeners 메서드 값을 씁니다.

public:
 static void Write(System::Object ^ value);
[System.Diagnostics.Conditional("TRACE")]
public static void Write (object? value);
[System.Diagnostics.Conditional("TRACE")]
public static void Write (object value);
[<System.Diagnostics.Conditional("TRACE")>]
static member Write : obj -> unit
Public Shared Sub Write (value As Object)

매개 변수

value
Object

이름이 Object 에 전송되는 Listeners입니다.

특성

예제

다음 예제에서는 라는 generalSwitchTraceSwitch 만듭니다. 이 스위치는 코드 샘플 외부에서 설정됩니다.

스위치가 이상으로 설정된 TraceLevelError 경우 예제에서는 매개 변수Listenersvalue 이름을 에 출력합니다. 컬렉션에 수신기 Listeners 를 추가하는 방법에 대한 자세한 내용은 클래스를 참조하세요 TraceListenerCollection .

그런 다음 가 TraceLevelVerbose설정된 경우 예제에서는 첫 번째 메시지와 동일한 줄에 메시지를 출력합니다. 두 번째 메시지 뒤에 줄 종결자가 표시됩니다.

// Class-level declaration.
// Create a TraceSwitch.
private:
   static TraceSwitch^ generalSwitch = 
      gcnew TraceSwitch( "General", "Entire Application" );

public:
   static void MyErrorMethod( Object^ myObject )
   {
      #if defined(TRACE)
      // Write the message if the TraceSwitch level 
      // is set to Error or higher.
      if ( generalSwitch->TraceError )
      {
         Trace::Write( myObject );
      }
      
      // Write a second message if the TraceSwitch level
      // is set to Verbose.
      if ( generalSwitch->TraceVerbose )
      {
          Trace::WriteLine( " is not a valid value for this method." );
      }
      #endif
   }
// Class-level declaration.
 // Create a TraceSwitch.
 static TraceSwitch generalSwitch = new TraceSwitch("General", "Entire Application");

 static public void MyErrorMethod(Object myObject) {
    // Write the message if the TraceSwitch level is set to Error or higher.
    if(generalSwitch.TraceError)
       Trace.Write(myObject);

    // Write a second message if the TraceSwitch level is set to Verbose.
    if(generalSwitch.TraceVerbose)
       Trace.WriteLine(" is not a valid value for this method.");
 }
' Class-level declaration.
' Create a TraceSwitch.
Private Shared generalSwitch As New TraceSwitch("General", "Entire Application")    

Public Shared Sub MyErrorMethod(myObject As Object)
    ' Write the message if the TraceSwitch level is set to Error or higher.
    If generalSwitch.TraceError Then
        Trace.Write(myObject)
    End If 
    ' Write a second message if the TraceSwitch level is set to Verbose.
    If generalSwitch.TraceVerbose Then
        Trace.WriteLine(" is not a valid value for this method.")
    End If
End Sub

설명

기본적으로 출력은 의 DefaultTraceListenerinstance 기록됩니다.

이 메서드는 Write 추적 수신기의 메서드를 호출합니다.

참고

ASP.NET 웹 페이지에 맞게 조정된 추적 기능을 제공합니다. ASP.NET 페이지에서 추적 메시지를 작성하려면 속성을 사용합니다 Page.Trace .

기본적으로 ASP.NET 웹 페이지와 연결된 코드에서 문 Trace.Write("...") 은 속성의 Page.Trace 메서드에 Write 대한 호출입니다. 웹 페이지에서 클래스를 System.Diagnostics.Trace 사용하려면 네임스페이스(예 System.Diagnostics.Trace.Write("..."): )를 포함해야 합니다.

추가 정보

적용 대상

Write(String)

Source:
Trace.cs
Source:
Trace.cs
Source:
Trace.cs

Listeners 컬렉션의 추적 수신기에 메시지를 씁니다.

public:
 static void Write(System::String ^ message);
[System.Diagnostics.Conditional("TRACE")]
public static void Write (string? message);
[System.Diagnostics.Conditional("TRACE")]
public static void Write (string message);
[<System.Diagnostics.Conditional("TRACE")>]
static member Write : string -> unit
Public Shared Sub Write (message As String)

매개 변수

message
String

쓸 메시지입니다.

특성

예제

다음 예제에서는 라는 generalSwitchTraceSwitch 만듭니다. 이 스위치는 코드 샘플 외부에서 설정됩니다.

스위치가 이상으로 설정된 TraceLevelError 경우 예제에서는 첫 번째 오류 메시지를 에 Listeners출력합니다. 컬렉션에 수신기 Listeners 를 추가하는 방법에 대한 자세한 내용은 클래스를 참조하세요 TraceListenerCollection .

그런 다음 가 TraceLevel 로 설정된 Verbose경우 예제에서는 첫 번째 메시지와 동일한 줄에 두 번째 오류 메시지를 출력합니다. 줄 종결자는 두 번째 메시지를 따릅니다.

// Class-level declaration.
// Create a TraceSwitch.
private:
   static TraceSwitch^ generalSwitch = 
      gcnew TraceSwitch( "General", "Entire Application" );

public:
   static void MyErrorMethod()
   {
      // Write the message if the TraceSwitch level is set
      // to Error or higher.
      if ( generalSwitch->TraceError )
      {
         Trace::Write( "My error message. " );
      }
      
      // Write a second message if the TraceSwitch level is set
      // to Verbose.
      if ( generalSwitch->TraceVerbose )
      {
          Trace::WriteLine( "My second error message." );
      }
   }
// Class-level declaration.
 // Create a TraceSwitch.
 static TraceSwitch generalSwitch = new TraceSwitch("General", "Entire Application");

 static public void MyErrorMethod() {
    // Write the message if the TraceSwitch level is set to Error or higher.
    if(generalSwitch.TraceError)
       Trace.Write("My error message. ");

    // Write a second message if the TraceSwitch level is set to Verbose.
    if(generalSwitch.TraceVerbose)
       Trace.WriteLine("My second error message.");
 }
' Class-level declaration.
' Create a TraceSwitch.
Private Shared generalSwitch As New TraceSwitch("General", "Entire Application")    

Public Shared Sub MyErrorMethod()
    ' Write the message if the TraceSwitch level is set to Error or higher.
    If generalSwitch.TraceError Then
        Trace.Write("My error message. ")
    End If 
    ' Write a second message if the TraceSwitch level is set to Verbose.
    If generalSwitch.TraceVerbose Then
        Trace.WriteLine("My second error message.")
    End If
End Sub

설명

기본적으로 출력은 의 DefaultTraceListenerinstance 기록됩니다.

이 메서드는 Write 추적 수신기의 메서드를 호출합니다.

참고

ASP.NET 웹 페이지에 맞게 조정된 추적 기능을 제공합니다. ASP.NET 페이지에서 추적 메시지를 작성하려면 속성을 사용합니다 Page.Trace .

기본적으로 ASP.NET 웹 페이지와 연결된 코드에서 문 Trace.Write("...") 은 속성의 Page.Trace 메서드에 Write 대한 호출입니다. 웹 페이지에서 클래스를 System.Diagnostics.Trace 사용하려면 네임스페이스(예 System.Diagnostics.Trace.Write("..."): )를 포함해야 합니다.

추가 정보

적용 대상

Write(Object, String)

Source:
Trace.cs
Source:
Trace.cs
Source:
Trace.cs

ToString() 컬렉션의 추적 수신기에 범주 이름 및 개체의 Listeners 메서드 값을 씁니다.

public:
 static void Write(System::Object ^ value, System::String ^ category);
[System.Diagnostics.Conditional("TRACE")]
public static void Write (object? value, string? category);
[System.Diagnostics.Conditional("TRACE")]
public static void Write (object value, string category);
[<System.Diagnostics.Conditional("TRACE")>]
static member Write : obj * string -> unit
Public Shared Sub Write (value As Object, category As String)

매개 변수

value
Object

Object 이름이 Listeners로 전송됩니다.

category
String

출력을 구성하는 데 사용되는 범주 이름입니다.

특성

예제

다음 예제에서는 라는 generalSwitchTraceSwitch 만듭니다. 이 스위치는 코드 샘플 외부에서 설정됩니다.

스위치가 로 TraceLevelVerbose설정된 경우 예제에서는 및 categorymyObject 이름을 에 Listeners출력합니다. 컬렉션에 수신기 Listeners 를 추가하는 방법에 대한 자세한 내용은 클래스를 참조하세요 TraceListenerCollection .

그런 다음 가 TraceLevel 이상으로 설정된 Error 경우 예제에서는 첫 번째 메시지와 동일한 줄에 두 번째 오류 메시지를 출력합니다. 두 번째 메시지 뒤에 줄 종결자가 표시됩니다.

// Class-level declaration.
// Create a TraceSwitch.
private:
   static TraceSwitch^ generalSwitch = 
      gcnew TraceSwitch( "General", "Entire Application" );

public:
   static void MyErrorMethod( Object^ myObject, String^ category )
   {
      #if defined(TRACE)
      // Write the message if the TraceSwitch level is set to Verbose.
      if ( generalSwitch->TraceVerbose )
      {
         Trace::Write( myObject, category );
      }
      
      // Write a second message if the TraceSwitch level is set to 
      // Error or higher.
      if ( generalSwitch->TraceError )
      {
         Trace::WriteLine( " Object is not valid for this category." );
      }
      #endif
   }
// Class-level declaration.
 // Create a TraceSwitch.
 static TraceSwitch generalSwitch = new TraceSwitch("General", "Entire Application");

 static public void MyErrorMethod(Object myObject, string category) {
    // Write the message if the TraceSwitch level is set to Verbose.
    if(generalSwitch.TraceVerbose)
       Trace.Write(myObject, category);

    // Write a second message if the TraceSwitch level is set to Error or higher.
    if(generalSwitch.TraceError)
       Trace.WriteLine(" Object is not valid for this category.");
 }
' Class-level declaration.
' Create a TraceSwitch.
Private Shared generalSwitch As New TraceSwitch("General", "Entire Application")

Public Shared Sub MyErrorMethod(myObject As Object, category As String)
    ' Write the message if the TraceSwitch level is set to Verbose.
    If generalSwitch.TraceVerbose Then
        Trace.Write(myObject, category)
    End If 
    ' Write a second message if the TraceSwitch level is set to Error or higher.
    If generalSwitch.TraceError Then
        Trace.WriteLine(" Object is not valid for this category.")
    End If
End Sub

설명

기본적으로 출력은 의 DefaultTraceListenerinstance 기록됩니다.

매개 변수를 category 사용하여 출력 메시지를 그룹화할 수 있습니다.

이 메서드는 Write 추적 수신기의 메서드를 호출합니다.

참고

ASP.NET 웹 페이지에 맞게 조정된 추적 기능을 제공합니다. ASP.NET 페이지에서 추적 메시지를 작성하려면 속성을 사용합니다 Page.Trace .

기본적으로 ASP.NET 웹 페이지와 연결된 코드에서 문 Trace.Write("...") 은 속성의 Page.Trace 메서드에 Write 대한 호출입니다. 웹 페이지에서 클래스를 System.Diagnostics.Trace 사용하려면 네임스페이스(예 System.Diagnostics.Trace.Write("..."): )를 포함해야 합니다.

추가 정보

적용 대상

Write(String, String)

Source:
Trace.cs
Source:
Trace.cs
Source:
Trace.cs

Listeners 컬렉션의 추적 수신기에 범주 이름 및 메시지를 씁니다.

public:
 static void Write(System::String ^ message, System::String ^ category);
[System.Diagnostics.Conditional("TRACE")]
public static void Write (string? message, string? category);
[System.Diagnostics.Conditional("TRACE")]
public static void Write (string message, string category);
[<System.Diagnostics.Conditional("TRACE")>]
static member Write : string * string -> unit
Public Shared Sub Write (message As String, category As String)

매개 변수

message
String

쓸 메시지입니다.

category
String

출력을 구성하는 데 사용되는 범주 이름입니다.

특성

예제

다음 예제에서는 라는 generalSwitchTraceSwitch 만듭니다. 이 스위치는 코드 샘플 외부에서 설정됩니다.

스위치가 로 TraceLevelVerbose설정된 경우 예제에서는 첫 번째 오류 메시지를 에 Listeners출력합니다. 컬렉션에 수신기 Listeners 를 추가하는 방법에 대한 자세한 내용은 클래스를 참조하세요 TraceListenerCollection .

그런 다음 가 TraceLevel 이상으로 설정된 Error 경우 예제에서는 첫 번째 메시지와 동일한 줄에 두 번째 오류 메시지를 출력합니다. 두 번째 메시지 뒤에 줄 종결자가 표시됩니다.

// Class-level declaration.
// Create a TraceSwitch.
private:
   static TraceSwitch^ generalSwitch = 
      gcnew TraceSwitch( "General", "Entire Application" );

public:
   static void MyErrorMethod( Object^ myObject, String^ category )
   {
      #if defined(TRACE)
      // Write the message if the TraceSwitch level is set to Verbose.
      if ( generalSwitch->TraceVerbose )
      {
         Trace::Write( String::Concat( myObject, 
            " is not a valid object for category: " ), category );
      }
      
      // Write a second message if the TraceSwitch level is set to
      // Error or higher.
      if ( generalSwitch->TraceError )
      {
         Trace::WriteLine( " Please use a different category." );
      }
      #endif
   }
// Class-level declaration.
 // Create a TraceSwitch.
 static TraceSwitch generalSwitch = new TraceSwitch("General", "Entire Application");

 static public void MyErrorMethod(Object myObject, string category) {
    // Write the message if the TraceSwitch level is set to Verbose.
    if(generalSwitch.TraceVerbose)
       Trace.Write(myObject.ToString() + " is not a valid object for category: ",
          category);

    // Write a second message if the TraceSwitch level is set to Error or higher.
    if(generalSwitch.TraceError)
       Trace.WriteLine(" Please use a different category.");
 }
' Class-level declaration.
' Create a TraceSwitch.
Private Shared generalSwitch As New TraceSwitch("General", "Entire Application")

Public Shared Sub MyErrorMethod(myObject As Object, category As String)
    ' Write the message if the TraceSwitch level is set to Verbose.
    If generalSwitch.TraceVerbose Then
        Trace.Write(myObject.ToString() & _
            " is not a valid object for category: ", category)
    End If
    
    ' Write a second message if the TraceSwitch level is set to Error or higher.
    If generalSwitch.TraceError Then
        Trace.WriteLine(" Please use a different category.")
    End If
End Sub

설명

기본적으로 출력은 의 DefaultTraceListenerinstance 기록됩니다.

매개 변수를 category 사용하여 출력 메시지를 그룹화할 수 있습니다.

이 메서드는 Write 추적 수신기의 메서드를 호출합니다.

참고

ASP.NET 웹 페이지에 맞게 조정된 추적 기능을 제공합니다. ASP.NET 페이지에서 추적 메시지를 작성하려면 속성을 사용합니다 Page.Trace .

기본적으로 ASP.NET 웹 페이지와 연결된 코드에서 문 Trace.Write("...") 은 속성의 Page.Trace 메서드에 Write 대한 호출입니다. 웹 페이지에서 클래스를 System.Diagnostics.Trace 사용하려면 네임스페이스(예 System.Diagnostics.Trace.Write("..."): )를 포함해야 합니다.

추가 정보

적용 대상