Log Class
Provides a property and methods for writing event and exception information to the application's log listeners.
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
The Log type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Log() | Initializes a new instance of the Log class. |
![]() | Log(String) | Initializes a new instance of the Log class. |
| Name | Description | |
|---|---|---|
![]() | DefaultFileLogWriter | Gets the file the FileLogTraceListener object that underlies the Log object. |
![]() | TraceSource | Gets to the TraceSource object that underlies the Log object. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | InitializeWithDefaultsSinceNoConfigExists | Creates a new FileLogTraceListener object and adds it to the Listeners collection. |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | WriteEntry(String) | Writes a message to the application's log listeners. |
![]() | WriteEntry(String, TraceEventType) | Writes a message to the application's log listeners. |
![]() | WriteEntry(String, TraceEventType, Int32) | Writes a message to the application's log listeners. |
![]() | WriteException(Exception) | Writes exception information to the application's log listeners. |
![]() | WriteException(Exception, TraceEventType, String) | Writes exception information to the application's log listeners. |
![]() | WriteException(Exception, TraceEventType, String, Int32) | Writes exception information to the application's log listeners. |
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 (Visual Basic) 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 AspLog.
The following table lists examples of tasks involving the My.Application.Log object.
To | See |
|---|---|
Write event information to the application's log listeners | |
Write exception information to the application's log listeners | |
Determine where My.Application.Log writes information | Walkthrough: Determining Where My.Application.Log Writes Information (Visual Basic) |
Note |
|---|
The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: Resources. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes. |
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 (Visual Basic).
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
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
