Log.WriteEntry Method (String, TraceEventType)
Writes a message to the application's log listeners.
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
The WriteEntry method writes a message to the application's event log listeners.
In client applications, the Log object is available through the My.Application.Log object. In Web applications, the Log object is available through the My.Log object.
To learn which log listeners receive the WriteEntry method's messages, see Walkthrough: Determining Where My.Application.Log Writes Information (Visual Basic). You can change default log listeners. For more information, see Working with Application Logs in Visual Basic.
For overloads that do not take the id argument, the id written to the log is defined by the following table.
The following table lists examples of tasks involving the WriteEntry method.
Write event information to the application's log listeners
Determine where Log writes information
Windows Control Library
Web Control Library
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
This code example can run only within a client application. Change My.Application.Log.WriteEntry to My.Log.WriteEntry for Web applications.
Available since 2.0