Loupe - Log - Monitor - Resolve
Gibraltar.Agent Namespace / Log Class / RecordException Method
An exception object to record as a log message. This call is ignored if null.
The application subsystem or logging category that the message will be associated with.
True if the application can continue after this call, false if this is a fatal error and the application should not continue.
Example

In This Topic
    RecordException Method (Log)
    In This Topic
    Record an unexpected exception to the log without displaying a user prompt.
    Syntax
    'Declaration
     
    
    Public Shared Sub RecordException( _
       ByVal exception As Exception, _
       ByVal category As String, _
       Optional ByVal canContinue As Boolean _
    ) 
    public static void RecordException( 
       Exception exception,
       string category,
       bool canContinue
    )

    Parameters

    exception
    An exception object to record as a log message. This call is ignored if null.
    category
    The application subsystem or logging category that the message will be associated with.
    canContinue
    True if the application can continue after this call, false if this is a fatal error and the application should not continue.
    Remarks

    This method provides an easy way to record an exception as a separate message which will be attributed to the code location which threw the exception rather than where this method was called from. The category will default to "Exception" if null, and the message will be formatted automatically based on the exception. The severity will be determined by the canContinue parameter: Critical for fatal errors (canContinue is false), Error for non-fatal errors (canContinue is true).

    This method is intended for use with top-level exception catching for errors not anticipated in a specific operation, but when it is not appropriate to alert the user because the error does not impact their work flow or will be otherwise handled gracefully within the application. For unanticipated errors which disrupt a user activity, see the ReportException method.

    For localized exception catching (e.g. anticipating exceptions when opening a file) we recommend logging an appropriate, specific log message with the exception attached. (See TraceError, Error, and Write and other such methods; the message need not be of Error severity.)

    Example
    Shows an example of both the record and report exception commands. Only one needs to be used for any single exception.
    //this option records the exception but does not display any user interface.  
    Log.RecordException(ex, "Exceptions", true);
     
    //this option records the exception and displays a user interface, optionally waiting for the user 
    //to decide to continue or exit before returning.
    Log.ReportException(ex, "Exceptions", true, true);
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also