Log.WriteEntry 메서드

정의

애플리케이션의 로그 수신기에 메시지를 씁니다.

오버로드

Name Description
WriteEntry(String)

애플리케이션의 로그 수신기에 메시지를 씁니다.

WriteEntry(String, TraceEventType)

애플리케이션의 로그 수신기에 메시지를 씁니다.

WriteEntry(String, TraceEventType, Int32)

애플리케이션의 로그 수신기에 메시지를 씁니다.

WriteEntry(String)

애플리케이션의 로그 수신기에 메시지를 씁니다.

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

매개 변수

message
String

필수 사항입니다. 기록할 메시지입니다. 이 Nothing경우 message 빈 문자열이 사용됩니다.

예외

부분 신뢰가 있는 코드는 메서드를 호출하지만 완전 신뢰가 필요한 이벤트 로그 수신기에 씁니다.

예제

이 예제에서는 메서드를 사용하여 My.Application.Log.WriteEntry 추적 정보를 기록하는 방법을 보여줍니다. 자세한 내용은 방법: 로그 메시지 작성을 참조하세요.

Private Sub GetOpenFormTitles()
    Dim formTitles As New Collection

    Try
        For Each f As Form In My.Application.OpenForms
            ' Use a thread-safe method to get all form titles.
            formTitles.Add(GetFormTitle(f))
        Next
    Catch ex As Exception
        formTitles.Add("Error: " & ex.Message)
    End Try

    Form1.ListBox1.DataSource = formTitles
End Sub

Private Delegate Function GetFormTitleDelegate(f As Form) As String
Private Function GetFormTitle(f As Form) As String
    ' Check if the form can be accessed from the current thread.
    If Not f.InvokeRequired Then
        ' Access the form directly.
        Return f.Text
    Else
        ' Marshal to the thread that owns the form. 
        Dim del As GetFormTitleDelegate = AddressOf GetFormTitle
        Dim param As Object() = {f}
        Dim result As System.IAsyncResult = f.BeginInvoke(del, param)
        ' Give the form's thread a chance process function.
        System.Threading.Thread.Sleep(10)
        ' Check the result.
        If result.IsCompleted Then
            ' Get the function's return value.
            Return "Different thread: " & f.EndInvoke(result).ToString
        Else
            Return "Unresponsive thread"
        End If
    End If
End Function

이 코드 예제는 클라이언트 애플리케이션 내에서만 실행할 수 있습니다. 웹 애플리케이션에 My.Log.WriteEntry 대해 변경 My.Application.Log.WriteEntry 합니다.

설명

메서드는 WriteEntry 애플리케이션의 이벤트 로그 수신기에 메시지를 씁니다.

클라이언트 애플리케이션에서 개체를 Log 통해 개체를 My.Application.Log 사용할 수 있습니다. 웹 애플리케이션에서 개체를 Log 통해 개체를 My.Log 사용할 수 있습니다.

메서드의 메시지를 수신 WriteEntry 하는 로그 수신기를 알아보려면 연습: My.Application.Log에서 정보를 쓰는 위치 결정 연습을 참조하세요. 기본 로그 수신기를 변경할 수 있습니다. 자세한 내용은 애플리케이션 로그 작업을 참조하세요.

인수 id 를 사용하지 않는 오버로드의 id 경우 로그에 기록된 내용은 다음 표에 의해 정의됩니다.

severity 기본 id
Information 0
Warning 1
Error 2
Critical 3
Start 4
Stop 5
Suspend 6
Resume 7
Verbose 8
Transfer 9

다음 표에서는 메서드와 관련된 WriteEntry 작업의 예를 나열합니다.

받는 사람 보십시오
애플리케이션의 로그 수신기에 이벤트 정보 쓰기 방법: 로그 메시지 작성
정보를 쓰는 위치 Log 확인 안내: My.Application.Log에서 정보를 기록하는 위치 결정

프로젝트 유형별 가용성

프로젝트 형식 사용 가능
Windows 애플리케이션 Yes
클래스 라이브러리 Yes
콘솔 애플리케이션 Yes
Windows 컨트롤 라이브러리 Yes
웹 제어 라이브러리 No
Windows 서비스 Yes
웹 사이트 Yes

추가 정보

적용 대상

WriteEntry(String, TraceEventType)

애플리케이션의 로그 수신기에 메시지를 씁니다.

public:
 void WriteEntry(System::String ^ message, System::Diagnostics::TraceEventType severity);
public void WriteEntry(string message, System.Diagnostics.TraceEventType severity);
member this.WriteEntry : string * System.Diagnostics.TraceEventType -> unit
Public Sub WriteEntry (message As String, severity As TraceEventType)

매개 변수

message
String

필수 사항입니다. 기록할 메시지입니다. 이 Nothing경우 message 빈 문자열이 사용됩니다.

severity
TraceEventType

메시지 유형입니다. 기본적으로TraceEventType.Information.

예외

메시지 유형이 열거형 값 중 TraceEventType 하나가 아닙니다.

부분 신뢰가 있는 코드는 메서드를 호출하지만 완전 신뢰가 필요한 이벤트 로그 수신기에 씁니다.

예제

이 예제에서는 메서드를 사용하여 My.Application.Log.WriteEntry 추적 정보를 기록하는 방법을 보여줍니다. 자세한 내용은 방법: 로그 메시지 작성을 참조하세요.

Private Sub GetOpenFormTitles()
    Dim formTitles As New Collection

    Try
        For Each f As Form In My.Application.OpenForms
            ' Use a thread-safe method to get all form titles.
            formTitles.Add(GetFormTitle(f))
        Next
    Catch ex As Exception
        formTitles.Add("Error: " & ex.Message)
    End Try

    Form1.ListBox1.DataSource = formTitles
End Sub

Private Delegate Function GetFormTitleDelegate(f As Form) As String
Private Function GetFormTitle(f As Form) As String
    ' Check if the form can be accessed from the current thread.
    If Not f.InvokeRequired Then
        ' Access the form directly.
        Return f.Text
    Else
        ' Marshal to the thread that owns the form. 
        Dim del As GetFormTitleDelegate = AddressOf GetFormTitle
        Dim param As Object() = {f}
        Dim result As System.IAsyncResult = f.BeginInvoke(del, param)
        ' Give the form's thread a chance process function.
        System.Threading.Thread.Sleep(10)
        ' Check the result.
        If result.IsCompleted Then
            ' Get the function's return value.
            Return "Different thread: " & f.EndInvoke(result).ToString
        Else
            Return "Unresponsive thread"
        End If
    End If
End Function

이 코드 예제는 클라이언트 애플리케이션 내에서만 실행할 수 있습니다. 웹 애플리케이션에 My.Log.WriteEntry 대해 변경 My.Application.Log.WriteEntry 합니다.

설명

메서드는 WriteEntry 애플리케이션의 이벤트 로그 수신기에 메시지를 씁니다.

클라이언트 애플리케이션에서 개체를 Log 통해 개체를 My.Application.Log 사용할 수 있습니다. 웹 애플리케이션에서 개체를 Log 통해 개체를 My.Log 사용할 수 있습니다.

메서드의 메시지를 수신 WriteEntry 하는 로그 수신기를 알아보려면 연습: My.Application.Log에서 정보를 쓰는 위치 결정 연습을 참조하세요. 기본 로그 수신기를 변경할 수 있습니다. 자세한 내용은 애플리케이션 로그 작업을 참조하세요.

인수 id 를 사용하지 않는 오버로드의 id 경우 로그에 기록된 내용은 다음 표에 의해 정의됩니다.

severity 기본 id
Information 0
Warning 1
Error 2
Critical 3
Start 4
Stop 5
Suspend 6
Resume 7
Verbose 8
Transfer 9

다음 표에서는 메서드와 관련된 WriteEntry 작업의 예를 나열합니다.

받는 사람 보십시오
애플리케이션의 로그 수신기에 이벤트 정보 쓰기 방법: 로그 메시지 작성
정보를 쓰는 위치 Log 확인 안내: My.Application.Log에서 정보를 기록하는 위치 결정

프로젝트 유형별 가용성

프로젝트 형식 사용 가능
Windows 애플리케이션 Yes
클래스 라이브러리 Yes
콘솔 애플리케이션 Yes
Windows 컨트롤 라이브러리 Yes
웹 제어 라이브러리 No
Windows 서비스 Yes
웹 사이트 Yes

추가 정보

적용 대상

WriteEntry(String, TraceEventType, Int32)

애플리케이션의 로그 수신기에 메시지를 씁니다.

public:
 void WriteEntry(System::String ^ message, System::Diagnostics::TraceEventType severity, int id);
public void WriteEntry(string message, System.Diagnostics.TraceEventType severity, int id);
member this.WriteEntry : string * System.Diagnostics.TraceEventType * int -> unit
Public Sub WriteEntry (message As String, severity As TraceEventType, id As Integer)

매개 변수

message
String

필수 사항입니다. 기록할 메시지입니다. 이 Nothing경우 message 빈 문자열이 사용됩니다.

severity
TraceEventType

메시지 유형입니다. 기본적으로TraceEventType.Information.

id
Int32

일반적으로 상관 관계에 사용되는 메시지 식별자입니다. 기본적으로 테이블에 설명된 대로 관련 entryType 됩니다.

예외

메시지 유형이 열거형 값 중 TraceEventType 하나가 아닙니다.

부분 신뢰가 있는 코드는 메서드를 호출하지만 완전 신뢰가 필요한 이벤트 로그 수신기에 씁니다.

예제

이 예제에서는 메서드를 사용하여 My.Application.Log.WriteEntry 추적 정보를 기록하는 방법을 보여줍니다. 자세한 내용은 방법: 로그 메시지 작성을 참조하세요.

Private Sub GetOpenFormTitles()
    Dim formTitles As New Collection

    Try
        For Each f As Form In My.Application.OpenForms
            ' Use a thread-safe method to get all form titles.
            formTitles.Add(GetFormTitle(f))
        Next
    Catch ex As Exception
        formTitles.Add("Error: " & ex.Message)
    End Try

    Form1.ListBox1.DataSource = formTitles
End Sub

Private Delegate Function GetFormTitleDelegate(f As Form) As String
Private Function GetFormTitle(f As Form) As String
    ' Check if the form can be accessed from the current thread.
    If Not f.InvokeRequired Then
        ' Access the form directly.
        Return f.Text
    Else
        ' Marshal to the thread that owns the form. 
        Dim del As GetFormTitleDelegate = AddressOf GetFormTitle
        Dim param As Object() = {f}
        Dim result As System.IAsyncResult = f.BeginInvoke(del, param)
        ' Give the form's thread a chance process function.
        System.Threading.Thread.Sleep(10)
        ' Check the result.
        If result.IsCompleted Then
            ' Get the function's return value.
            Return "Different thread: " & f.EndInvoke(result).ToString
        Else
            Return "Unresponsive thread"
        End If
    End If
End Function

이 코드 예제는 클라이언트 애플리케이션 내에서만 실행할 수 있습니다. 웹 애플리케이션에 My.Log.WriteEntry 대해 변경 My.Application.Log.WriteEntry 합니다.

설명

메서드는 WriteEntry 애플리케이션의 이벤트 로그 수신기에 메시지를 씁니다.

클라이언트 애플리케이션에서 개체를 Log 통해 개체를 My.Application.Log 사용할 수 있습니다. 웹 애플리케이션에서 개체를 Log 통해 개체를 My.Log 사용할 수 있습니다.

메서드의 메시지를 수신 WriteEntry 하는 로그 수신기를 알아보려면 연습: My.Application.Log에서 정보를 쓰는 위치 결정 연습을 참조하세요. 기본 로그 수신기를 변경할 수 있습니다. 자세한 내용은 애플리케이션 로그 작업을 참조하세요.

인수 id 를 사용하지 않는 오버로드의 id 경우 로그에 기록된 내용은 다음 표에 의해 정의됩니다.

severity 기본 id
Information 0
Warning 1
Error 2
Critical 3
Start 4
Stop 5
Suspend 6
Resume 7
Verbose 8
Transfer 9

다음 표에서는 메서드와 관련된 WriteEntry 작업의 예를 나열합니다.

받는 사람 보십시오
애플리케이션의 로그 수신기에 이벤트 정보 쓰기 방법: 로그 메시지 작성
정보를 쓰는 위치 Log 확인 안내: My.Application.Log에서 정보를 기록하는 위치 결정

프로젝트 유형별 가용성

프로젝트 형식 사용 가능
Windows 애플리케이션 Yes
클래스 라이브러리 Yes
콘솔 애플리케이션 Yes
Windows 컨트롤 라이브러리 Yes
웹 제어 라이브러리 No
Windows 서비스 Yes
웹 사이트 Yes

추가 정보

적용 대상