Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Log.WriteEntry Method (String, TraceEventType)

Writes a message to the application's log listeners.

Namespace:  Microsoft.VisualBasic.Logging
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
public void WriteEntry(
	string message,
	TraceEventType severity
)

Parameters

message
Type: System.String

Required. The message to log. If message is Nothing, an empty string is used.

severity
Type: System.Diagnostics.TraceEventType

The type of message. By default, TraceEventType.Information.

ExceptionCondition
InvalidEnumArgumentException

The message type is not one of the TraceEventType enumeration values.

SecurityException

Code with partial trust calls the method, but writes to an event log listener that requires full trust.

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.

To

See

Write event information to the application's log listeners

How to: Write Log Messages (Visual Basic)

Determine where Log writes information

Walkthrough: Determining Where My.Application.Log Writes Information (Visual Basic)

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

Yes

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.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.