Udostępnij za pośrednictwem


My.Application.Log Object

Provides a property and methods to write event and exception information to the application's log listeners.

Remarks

The My.Application.Log object provides a straightforward entry point from which to access the .NET Framework's logging services. The WriteEntry and WriteException methods write messages to the application's log listeners. The listeners can be configured by the application's configuration file. For more information, see Walkthrough: Changing Where My.Application.Log Writes Information and Working with Application Logs in Visual Basic.

The My.Application.Log object is available only for client applications. For Web applications, use My.Log. For more information, see My.Log Object.

Tasks

The following table lists examples of tasks that involve the My.Application.Log object.

To

See

Write event information to the application's log listeners

How to: Write Log Messages

Write exception information to the application's log listeners

How to: Log Exceptions in Visual Basic

Determine where My.Application.Log writes information

Walkthrough: Determining Where My.Application.Log Writes Information

Example

This example shows how to use the My.Application.Log.WriteEntry method to log tracing information. For more information, see How to: Write Log Messages.

Public Sub TracingTest(ByVal fileName As String)
    My.Application.Log.WriteEntry( _
        "Entering TracingTest with argument " & _
        fileName & ".")
    ' Code to trace goes here.
    My.Application.Log.WriteEntry( _
        "Exiting TracingTest with argument " & _
        fileName & ".")
End Sub

Requirements

Namespace:Microsoft.VisualBasic.Logging

Class:Log

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Availability by Project Type

Project type

Available

Windows Application

Yes

Class Library

Yes

Console Application

Yes

Windows Control Library

Yes

Web Control Library

No

Windows Service

Yes

Web Site

No

See Also

Reference

My.Application.Log Object Members

My.Application Object