Skip navigation FileNet logo
  Open Client Developer's Guide
  Search  |  Index  |  Glossary   |  
Open menu Overview
Open menu Open Client Architecture
Open menu Developing for Process
Close menu Error and Exception Handling
  Open menu Error Handling
  Close menu Exception Handling
    Defining a New Exception
    Error Helper Functions
    Handling Guidelines
    Handling COMException
    Logging Exceptions
Open menu Customizing the Framework
Globalization / Localization
Open menu General Information
   

Logging Exceptions

ASP.NET introduces a new application-level event, Application_Error, that can be handled within the ..\FileNet\IDM\Web\FNOpenClient\Global.asax file. This method gets called during the processing of a Web request, whenever an unhandled exception occurs either within your application or another component. The .NET framework also includes a mechanism that writes these unhandled exceptions to a Microsoft Windows Event Log named IdmWSXLog.

While developers are encouraged to also use IdmWSXLog for logging exceptions of interest, they are recommended to only log essential information. By using this mechanism, developers can obtain specific information about both the calling request that caused the exception, such as:

  • the url of the invalid page
  • the arguments of the query string
  • the user agent
  • cookies

and the actual Exception object that encapsulates the error information.

When notifying events, developers are recommended to structure event log calls along a separate “error path” within the application, rather than scattering the calls throughout the main code path. For example:

Sub Application_Error(ByVal Sender As Object, ByVal E As EventArgs)
   'Obtain the URL of the Request
   Dim PageUrl As String = Request.Path
   'Obtain the Exception Object for the Error
   Dim ErrorInfo As Exception = Server.GetLastError()
   'Construct Error Message to Write to NT Event Log
   Dim Message As String = "Url " & PageUrl & " Error: " & ErrorInfo.ToString
   'NT Event Log Name to Write Message To
   Dim LogName As String = "IdmWSXLog"
   'Create Event Log if It Doesn’t Exist
   If (Not EventLog.SourceExists(LogName)) Then
      EventLog.CreateEventSource(LogName, LogName)
   End If
   'Fire off to Event Log
   Dim Log As New EventLog()
   Log.Source = LogName
   Log.WriteEntry(Message, EventLogEntryType.Error)
   Dim errObj As New FnError
   Dim rm As New FnResourceManager
   If ErrorInfo.InnerException.Message = FnGlobal.Lit_MSG_Request_timed_out And
   Request.Path = (Request.ApplicationPath & "/" & FnGlobal.Lit_Search_Page) Then
      Dim excSearch As FnWSException
      excSearch = errObj.SearchError(FN_ERR_SEARCH.LongSearchTimeOut)
      errObj.HandleException(excSearch, Request.RawUrl)
   Else
      errObj.HandleException(ErrorInfo)
   End If    
End Sub
' Application_error()

Then, at the page level, developers can use the Page_Error event to handle errors on a page:

Sub Page_Error(ByVal Sender As Object, ByVal E As EventArgs)
   'Obtain the URL of the Request
   Dim PageUrl As String = Request.Path
   'Obtain the Exception Object for the Error
   Dim ErrorInfo As Exception = Server.GetLastError()
   'Construct Error Message to Write to NT Event Log
   Dim Message As String
   Message = "Url " & PageUrl & " Error: " & ErrorInfo.ToString
   'Enter application-specific instructions after this line
   ...
End Sub

Doing so will reduce the risk of decreasing performance as a result of event logging.

Using the Trace Log

ASP.NET provides a very powerful tracing capability to aid debugging and testing your Web application. ASP.NET allows you to enable tracing at the application level in Web.Config. Otherwise, you can view the application trace log by browsing the "trace.axd" page from your Web application.

ASP.NET provides powerful tracing functionality that can be used to assist in debugging and testing Web applications. Tracing can be enabled at the application level, by specifying the following in the ..\FileNet\IDM\Web\FNOpenClient\Web.Config file:

<trace enabled="true" requestLimit="10" pageOutput="false" traceMode="SortByTime" />

Once tracing has been enabled for the application, each page in the application will execute any page-level trace statements that they contain. Whenever pageOutput="true", the trace information is displayed at the bottom of the corresponding page.

The application trace log can be viewed within the Web application by navigating to the http://localhost/idmwsx/trace.axd page in the browser. To activate the trace log for a specific Web aspx page, set Trace to “true” in the page control declaration:

<%@ Page Trace=”true” %>

To add additional information to the trace log, use the Write method of the Trace object:

Trace.Write(“Message”,“Function Name Enter”)