Log Kelas
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menyediakan properti dan metode untuk menulis informasi peristiwa dan pengecualian ke pendengar log aplikasi.
public ref class Log
public class Log
type Log = class
Public Class Log
- Warisan
-
Log
- Turunan
Contoh
Contoh ini menunjukkan cara menggunakan My.Application.Log.WriteEntry metode untuk mencatat informasi pelacakan. Untuk informasi selengkapnya, lihat Cara: Menulis Pesan Log.
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
Keterangan
Objek My.Application.Log menyediakan titik masuk langsung untuk mengakses layanan pengelogan .NET Framework. Metode WriteEntry dan WriteException menulis pesan ke pendengar log aplikasi. Pendengar dapat dikonfigurasi oleh file konfigurasi aplikasi. Untuk informasi selengkapnya, lihat Panduan: Mengubah Tempat My.Application.Log Menulis Informasi dan Bekerja dengan Log Aplikasi.
Objek My.Application.Log hanya tersedia untuk aplikasi klien. Untuk aplikasi Web, gunakan My.Log. Untuk informasi selengkapnya, lihat AspLog .
Tabel berikut ini mencantumkan contoh tugas yang melibatkan My.Application.Log objek.
| Untuk | Lihat |
|---|---|
| Menulis informasi peristiwa ke pendengar log aplikasi | Cara: Menulis Pesan Log |
| Menulis informasi pengecualian ke pendengar log aplikasi | Cara Mencatat Pengecualian |
Menentukan tempat My.Application.Log menulis informasi |
Panduan: Menentukan Di mana My.Application.Log Menulis Informasi |
Konstruktor
| Nama | Deskripsi |
|---|---|
| Log() |
Menginisialisasi instans baru dari kelas Log. |
| Log(String) |
Menginisialisasi instans baru dari kelas Log. |
Properti
| Nama | Deskripsi |
|---|---|
| DefaultFileLogWriter |
Mendapatkan file FileLogTraceListener objek yang mendasar |
| TraceSource |
Masuk ke TraceSource objek yang mendasar objek |
Metode
| Nama | Deskripsi |
|---|---|
| Equals(Object) |
Menentukan apakah objek yang ditentukan sama dengan objek saat ini. (Diperoleh dari Object) |
| GetHashCode() |
Berfungsi sebagai fungsi hash default. (Diperoleh dari Object) |
| GetType() |
Mendapatkan Type instans saat ini. (Diperoleh dari Object) |
| InitializeWithDefaultsSinceNoConfigExists() |
Membuat objek baru FileLogTraceListener dan menambahkannya ke Listeners koleksi. |
| MemberwiseClone() |
Membuat salinan dangkal dari Objectsaat ini. (Diperoleh dari Object) |
| ToString() |
Mengembalikan string yang mewakili objek saat ini. (Diperoleh dari Object) |
| WriteEntry(String, TraceEventType, Int32) |
Menulis pesan ke pendengar log aplikasi. |
| WriteEntry(String, TraceEventType) |
Menulis pesan ke pendengar log aplikasi. |
| WriteEntry(String) |
Menulis pesan ke pendengar log aplikasi. |
| WriteException(Exception, TraceEventType, String, Int32) |
Menulis informasi pengecualian ke pendengar log aplikasi. |
| WriteException(Exception, TraceEventType, String) |
Menulis informasi pengecualian ke pendengar log aplikasi. |
| WriteException(Exception) |
Menulis informasi pengecualian ke pendengar log aplikasi. |