AspLog クラス

定義

イベントと例外の情報をアプリケーションのログ リスナーに書き込むためのプロパティとメソッドを提供します。

public ref class AspLog : Microsoft::VisualBasic::Logging::Log
public class AspLog : Microsoft.VisualBasic.Logging.Log
type AspLog = class
    inherit Log
Public Class AspLog
Inherits Log
継承
AspLog

この例では、 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.Application.Log オブジェクトは、.NET Framework のログ サービスにアクセスするための簡単なエントリ ポイントを提供します。 WriteEntryメソッドとWriteException メソッドは、アプリケーションのログ リスナーにメッセージを書き込みます。 リスナーは、アプリケーションの構成ファイルによって構成できます。 詳細については、「 チュートリアル: My.Application.Log が情報を書き込む場所の変更アプリケーション ログの操作」を参照してください。

My.Application.Log オブジェクトは、クライアント アプリケーションでのみ使用できます。 Web アプリケーションの場合は、 My.Logを使用します。 詳細については、Microsoft.VisualBasic.Logging.Logを参照してください。

次の表に、 My.Application.Log オブジェクトに関連するタスクの例を示します。

ターゲット 参照先
アプリケーションのログ リスナーにイベント情報を書き込む 方法: ログ メッセージを書き込む
アプリケーションのログ リスナーに例外情報を書き込む 方法: 例外をログに記録する
My.Application.Logが情報を書き込む場所を決定する チュートリアル: My.Application.Log が情報を書き込む場所の決定

コンストラクター

名前 説明
AspLog()

AspLog クラスの新しいインスタンスを初期化します。

AspLog(String)

AspLog クラスの新しいインスタンスを初期化します。

プロパティ

名前 説明
DefaultFileLogWriter

FileLogTraceListener オブジェクトの基になるLog オブジェクトのファイルを取得します。

(継承元 Log)
TraceSource

TraceSource オブジェクトの基になるLog オブジェクトを取得します。

(継承元 Log)

メソッド

名前 説明
Equals(Object)

指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
InitializeWithDefaultsSinceNoConfigExists()

新しい FileLogTraceListener を作成し、 Listeners コレクションに追加します。

MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
WriteEntry(String, TraceEventType, Int32)

アプリケーションのログ リスナーにメッセージを書き込みます。

(継承元 Log)
WriteEntry(String, TraceEventType)

アプリケーションのログ リスナーにメッセージを書き込みます。

(継承元 Log)
WriteEntry(String)

アプリケーションのログ リスナーにメッセージを書き込みます。

(継承元 Log)
WriteException(Exception, TraceEventType, String, Int32)

アプリケーションのログ リスナーに例外情報を書き込みます。

(継承元 Log)
WriteException(Exception, TraceEventType, String)

アプリケーションのログ リスナーに例外情報を書き込みます。

(継承元 Log)
WriteException(Exception)

アプリケーションのログ リスナーに例外情報を書き込みます。

(継承元 Log)

適用対象

こちらもご覧ください