ApplicationBase.Log 속성

정의

애플리케이션의 로그 수신기에 이벤트 및 예외 정보를 쓰기 위한 속성 및 메서드를 제공하는 개체를 가져옵니다.

public:
 property Microsoft::VisualBasic::Logging::Log ^ Log { Microsoft::VisualBasic::Logging::Log ^ get(); };
public Microsoft.VisualBasic.Logging.Log Log { get; }
member this.Log : Microsoft.VisualBasic.Logging.Log
Public ReadOnly Property Log As Log

속성 값

Log

Log 현재 애플리케이션의 개체입니다.

예제

이 예제에서는 메서드를 사용하여 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

적용 대상

추가 정보