WriteEntry Method


WriteEntry Method

Location

My.Application.Log.WriteEntry

My.Log.WriteEntry

Syntax

For client applications:

 My.Application.Log.WriteEntry(message[, severity[, id]]) 

For ASP.NET applications:

 My.Log.WriteEntry(message[, severity[, id]]) 


message (required; String)

The message to log or an empty string if there is no message.


severity (optional; TraceEventType enumeration)

The type of message to log. One of the following System.Diagnostics.TraceEventType enumeration values.

Value

Description

Default ID

Critical

Application fatal error or crash event

3

Error

Recoverable error event

2

Information

Non-debugging informational message

0

None

Undefined event type

 

Resume

Resumption of a logical operation

7

Start

Starting of a logical operation

4

Stop

Stopping of a logical operation

5

Suspend

Suspension of a logical operation

6

TRansfer

Transfer of control to another logical operation

9

Verbose

Debugging informational message

8

Warning

Noncritical event

1


If severity is not supplied, Information is used by default.


id (optional; Integer)

The programmer-defined identifier for this entry. If id is not supplied, a pre-defined value associated with the TraceEventType enumeration is used. See the Default ID column in the table of TraceEventType enumeration values discussed above in the entry for the severity parameter.

Description

The WriteEntry method writes a message to the application's configured event log listeners.

Usage at a Glance

  • This method is only valid in client and ASP.NET applications. For client applications, use My.Application.Log.WriteEntry. For ASP.NET applications, use My.Log.WriteEntry.

  • For more information about using log listeners, see the TraceSource Property entry.

  • An exception is thrown if you lack sufficient privileges to write to one of the configured log listeners.

  • An exception is thrown if you specify an invalid severity.

Example

The following example writes an informational message (the default) to the configured logs from a client application.

 My.Application.Log.WriteEntry("Please read this; it's important.") 

To write the same log message from an ASP.NET application, use this statement instead.

 My.Log.WriteEntry("Please read this; it's important.") 

Related Framework Entries

  • Microsoft.VisualBasic.Logging.Log.WriteEntry Method

  • System.Diagnostics.TraceListener Class

See Also

DefaultFileLogWriter Property, Log Object (My), Log Object (My.Application), TraceSource Property, WriteException Method




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net