Trace.Write 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
추적에 대한 정보를 컬렉션의 추적 수신기에 Listeners 씁니다.
오버로드
| Name | Description |
|---|---|
| Write(Object) |
컬렉션의 추적 수신기 Listeners 에 개체 메서드의 ToString() 값을 씁니다. |
| Write(String) |
컬렉션의 추적 수신기 Listeners 에 메시지를 씁니다. |
| Write(Object, String) |
컬렉션의 추적 수신기 Listeners 에 범주 이름 및 개체 ToString() 메서드 값을 씁니다. |
| Write(String, String) |
컬렉션의 추적 수신기 Listeners 에 범주 이름 및 메시지를 씁니다. |
Write(Object)
- Source:
- Trace.cs
- Source:
- Trace.cs
- Source:
- Trace.cs
- Source:
- Trace.cs
- Source:
- Trace.cs
컬렉션의 추적 수신기 Listeners 에 개체 메서드의 ToString() 값을 씁니다.
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)
매개 변수
- 특성
예제
다음 예제에서는 명명generalSwitch된 .TraceSwitch 이 스위치는 코드 샘플 외부에서 설정됩니다.
스위치가 더 높은 값으로 TraceLevelError 설정된 경우 이 예제에서는 매개 변수Listeners의 value 이름을 .에 출력합니다. 컬렉션에 수신기 Listeners 를 추가하는 방법에 대한 자세한 내용은 클래스를 TraceListenerCollection 참조하세요.
그런 다음, 설정된 Verbose경우 TraceLevel 예제에서는 첫 번째 메시지와 동일한 줄에 메시지를 출력합니다. 두 번째 메시지 뒤에 줄 종결자가 잇습니다.
// 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
설명
기본적으로 출력은 .의 DefaultTraceListener인스턴스에 기록됩니다.
이 메서드는 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
- 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
쓸 메시지입니다.
- 특성
예제
다음 예제에서는 명명generalSwitch된 .TraceSwitch 이 스위치는 코드 샘플 외부에서 설정됩니다.
스위치가 더 높은 값으로 TraceLevelError 설정된 경우 예제에서는 첫 번째 오류 메시지를 Listeners출력합니다. 컬렉션에 수신기 Listeners 를 추가하는 방법에 대한 자세한 내용은 클래스를 TraceListenerCollection 참조하세요.
그런 다음, 설정된 Verbose경우 TraceLevel 예제에서는 첫 번째 메시지와 동일한 줄에 두 번째 오류 메시지를 출력합니다. 줄 종결자는 두 번째 메시지를 따릅니다.
// 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
설명
기본적으로 출력은 .의 DefaultTraceListener인스턴스에 기록됩니다.
이 메서드는 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
- Source:
- Trace.cs
- Source:
- Trace.cs
컬렉션의 추적 수신기 Listeners 에 범주 이름 및 개체 ToString() 메서드 값을 씁니다.
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)
매개 변수
- category
- String
출력을 구성하는 데 사용되는 범주 이름입니다.
- 특성
예제
다음 예제에서는 명명generalSwitch된 .TraceSwitch 이 스위치는 코드 샘플 외부에서 설정됩니다.
스위치가 해당 스위치로 TraceLevel설정된 경우 예제에서는 이름과 이름을 출력합니다 ListenersmyObjectcategory.Verbose 컬렉션에 수신기 Listeners 를 추가하는 방법에 대한 자세한 내용은 클래스를 TraceListenerCollection 참조하세요.
그런 다음, 이 값이 이상으로 설정된 Error 경우 TraceLevel 예제에서는 첫 번째 메시지와 동일한 줄에 두 번째 오류 메시지를 출력합니다. 두 번째 메시지 뒤에 줄 종결자가 잇습니다.
// 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
설명
기본적으로 출력은 .의 DefaultTraceListener인스턴스에 기록됩니다.
매개 변수를 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
- 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
출력을 구성하는 데 사용되는 범주 이름입니다.
- 특성
예제
다음 예제에서는 명명generalSwitch된 .TraceSwitch 이 스위치는 코드 샘플 외부에서 설정됩니다.
스위치가 로 설정된 TraceLevelVerbose경우 예제에서는 첫 번째 오류 메시지를 Listeners출력합니다. 컬렉션에 수신기 Listeners 를 추가하는 방법에 대한 자세한 내용은 클래스를 TraceListenerCollection 참조하세요.
그런 다음, 이 값이 이상으로 설정된 Error 경우 TraceLevel 예제에서는 첫 번째 메시지와 동일한 줄에 두 번째 오류 메시지를 출력합니다. 두 번째 메시지 뒤에 줄 종결자가 잇습니다.
// 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
설명
기본적으로 출력은 .의 DefaultTraceListener인스턴스에 기록됩니다.
매개 변수를 category 사용하여 출력 메시지를 그룹화할 수 있습니다.
이 메서드는 Write 추적 수신기의 메서드를 호출합니다.
메모
ASP.NET 웹 페이지에 맞게 조정된 추적 기능을 제공합니다. ASP.NET 페이지에서 추적 메시지를 작성하려면 이 속성을 사용합니다 Page.Trace .
기본적으로 ASP.NET 웹 페이지와 연결된 코드에서 문 Trace.Write("...") 은 속성의 Page.Trace 메서드에 Write 대한 호출입니다. 웹 페이지에서 클래스를 System.Diagnostics.Trace 사용하려면 네임스페이스를 포함해야 합니다. 예를 들면 다음과 같습니다 System.Diagnostics.Trace.Write("...").