다음을 통해 공유


TraceContext.Warn 메서드

정의

추적 정보를 추적 로그에 씁니다. 달리 Write(String)모든 경고는 로그에 빨간색 텍스트로 표시됩니다.

오버로드

Name Description
Warn(String)

추적 로그에 추적 메시지를 씁니다. 모든 경고는 로그에 빨간색 텍스트로 표시됩니다.

Warn(String, String)

사용자 정의 범주 및 추적 메시지를 포함하여 추적 정보를 추적 로그에 씁니다. 모든 경고는 로그에 빨간색 텍스트로 표시됩니다.

Warn(String, String, Exception)

사용자 정의 범주, 추적 메시지 및 오류 정보를 포함하여 추적 정보를 추적 로그에 씁니다. 모든 경고는 로그에 빨간색 텍스트로 표시됩니다.

Warn(String)

추적 로그에 추적 메시지를 씁니다. 모든 경고는 로그에 빨간색 텍스트로 표시됩니다.

public:
 void Warn(System::String ^ message);
public void Warn(string message);
member this.Warn : string -> unit
Public Sub Warn (message As String)

매개 변수

message
String

로그에 쓸 추적 메시지입니다.

설명

메서드를 Warn 호출 TraceContext 할 때마다 추적 메시지가 메시지 컬렉션에 TraceRecords 추가되며 이벤트를 처리 TraceFinished 할 때 액세스할 수 있습니다. 메시지는 해당 속성이 설정되고 해당 IsWarning 속성이 ErrorInfo .로 설정된 상태로 추가됩니다null.true

추가 정보

적용 대상

Warn(String, String)

사용자 정의 범주 및 추적 메시지를 포함하여 추적 정보를 추적 로그에 씁니다. 모든 경고는 로그에 빨간색 텍스트로 표시됩니다.

public:
 void Warn(System::String ^ category, System::String ^ message);
public void Warn(string category, string message);
member this.Warn : string * string -> unit
Public Sub Warn (category As String, message As String)

매개 변수

category
String

메시지를 받는 추적 범주입니다.

message
String

로그에 쓸 추적 메시지입니다.

설명

메서드를 Warn 호출 TraceContext 할 때마다 추적 메시지가 메시지 컬렉션에 TraceRecords 추가되며 이벤트를 처리 TraceFinished 할 때 액세스할 수 있습니다. 메시지는 해당 속성이 설정되고 해당 IsWarning 속성이 ErrorInfo .로 설정된 상태로 추가됩니다null.true

추가 정보

적용 대상

Warn(String, String, Exception)

사용자 정의 범주, 추적 메시지 및 오류 정보를 포함하여 추적 정보를 추적 로그에 씁니다. 모든 경고는 로그에 빨간색 텍스트로 표시됩니다.

public:
 void Warn(System::String ^ category, System::String ^ message, Exception ^ errorInfo);
public void Warn(string category, string message, Exception errorInfo);
member this.Warn : string * string * Exception -> unit
Public Sub Warn (category As String, message As String, errorInfo As Exception)

매개 변수

category
String

메시지를 받는 추적 범주입니다.

message
String

로그에 쓸 추적 메시지입니다.

errorInfo
Exception

Exception 오류에 대한 정보가 들어 있는 항목입니다.

예제

다음 코드 예제에서는 추적 로그에 Write 오류 추적 메시지를 작성 하는 메서드를 호출 하는 방법을 보여 줍니다. 이 예제에서는 다른 예외가 오류 및 경고로 추적됩니다. 페이지가 ArgumentExceptionthrow되면 메서드를 사용하여 Warn 경고 메시지를 씁니다. 페이지가 InvalidOperationExceptionthrow되면 메서드를 사용하여 Write 오류 메시지를 씁니다.

<%@ Page language="c#" Trace="true" %>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
    // Register a handler for the TraceFinished event.
    Trace.TraceFinished += new 
        TraceContextEventHandler(this.OnTraceFinished);

    try {
        throw new ArgumentException("Trace Test");
    }
    catch (InvalidOperationException ioe) {    
        // You can write an error trace message using the Write method.
        Trace.Write("Exception Handling", "Exception: Page_Load.", ioe);
    }
    catch (ArgumentException ae) {    
        // You can write a warning trace message using the Warn method.
        Trace.Warn("Exception Handling", "Warning: Page_Load.", ae);
    }
}
 
// A TraceContextEventHandler for the TraceFinished event.
void OnTraceFinished(object sender, TraceContextEventArgs e)
{
    TraceContextRecord r = null;    
    
    // Iterate through the collection of trace records and write 
    // them to the response stream.
    foreach(object o in e.TraceRecords)
    { 
        r = (TraceContextRecord)o;
        if (r.IsWarning) {
            Response.Write(String.Format("warning message: {0} <BR>", r.Message));
        }
        else {
            Response.Write(String.Format("error message: {0} <BR>", r.Message));
        }

    }
}       
</script>
<%@ Page language="VB" Trace="true" %>
<script runat="server">
' The Page_Load method.
Private Sub Page_Load(sender As Object, e As EventArgs)

    ' Register a handler for the TraceFinished event.
    AddHandler Trace.TraceFinished, AddressOf OnTraceFinished

    Try 
    Dim ae As New ArgumentException("Trace Test")
        Throw ae
    
    catch ioe As InvalidOperationException
        ' You can write an error trace message using the Write method.
        Trace.Write("Exception Handling", "Exception: Page_Load.", ioe)
    
    Catch ae As ArgumentException
        ' You can write a warning trace message using the Warn method.
        Trace.Warn("Exception Handling", "Warning: Page_Load.", ae)

    End Try

End Sub ' Page_Load
 
' A TraceContextEventHandler for the TraceFinished event.
Private Sub OnTraceFinished(sender As Object, e As TraceContextEventArgs)

    Dim r As TraceContextRecord
    Dim o As Object
    
    ' Iterate through the collection of trace records and write 
    ' them to the response stream.

    For Each o In e.TraceRecords
        r = CType(o, TraceContextRecord)
    If r.IsWarning Then
            Response.Write(String.Format("warning message: {0} <BR>", r.Message))
        Else
            Response.Write(String.Format("error message: {0} <BR>", r.Message))
        End If
    Next

End Sub	' OnTraceFinished
</script>

설명

메서드를 Warn 호출 TraceContext 할 때마다 추적 메시지가 메시지 컬렉션에 TraceRecords 추가되며 이벤트를 처리 TraceFinished 할 때 액세스할 수 있습니다. 메시지는 해당 IsWarning 속성이 설정된 상태로 true추가되고 ErrorInfo 속성은 매개 변수에서 전달된 개체로 설정됩니다 errorInfo .

추가 정보

적용 대상