Location My.Application.Log.WriteException My.Log.WriteException Syntax For client applications: My.Application.Log.WriteException(ex[, severity, _ additionalInfo[, id]]) For ASP.NET applications: My.Log.WriteException(ex[, severity, additionalInfo[, id]])
ex (required; System.Exception) The content of the exception to send to the log.
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.
additionalInfo (optional; String) A message that is appended to the logged message.
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 WriteException method writes an exception entry 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.WriteException. For ASP.NET applications, use My.Log.WriteException. 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 a exception warning message to the configured logs from a client application. Try ' ----- Important but exception-prone code here. Catch ex As System.Exception My.Application.Log.WriteException(ex, TraceEventType.Warning, _ "Will try again in five minutes.") End Try To write the same log message from an ASP.NET application, use this statement instead. Try ' ----- Important but exception-prone code here. Catch ex As System.Exception My.Log.WriteException(ex, TraceEventType.Warning, _ "Will try again in five minutes.") End Try Related Framework Entries See Also DefaultFileLogWriter Property, Log Object (My), Log Object (My.Application), TraceSource Property, WriteEntry Method |