Skip to main content link. Accesskey S

The useful resource for IBM Lotus Domino XPages development

Submit Search

Available in the Appstore!All the content of xpageswiki.com for iPhone or iPad for offline access.

Home > Server JavaScript > Debugging and error logging

Debugging and error logging

ShowTable of Contents

Show error page


The default error page does not tell you what was wrong.
Use Page Properties -> XPage -> "display default error page" while in development.
Reset this setting when going to production.

Error handling


Sourround your code with an error handler like this:

try {
...
} catch(e) {
    print("error: "+e);
}


The print() command prints out to the domino server console or dominodata/IBM_TECHNICAL_SUPPORT/console.log.

Using prints


You can use print() anywhere in your code to print out stuff to the domino server console or dominodata/IBM_TECHNICAL_SUPPORT/console.log.
If your server is on linux, you might want to use "tail -f <path to domino data>/IBM_TECHNICAL_SUPPORT/console.log".

Error logging


You can use the window.onerror event handler to create an automatic logging of javascript errors in the client:

window.onerror = function(errorMessage, url, line) {
  var loggerUrl = "/<path to db>/logErrors?OpenAgent";
  var parameters = "&description=" + escape(errorMessage)
      + "&amp;url=" + escape(url)
      + "&amp;line=" + escape(line)
      + "&amp;parent_url=" + escape(document.location.href)
      + "&amp;user_agent=" + escape(navigator.userAgent);
 
  /** Send error to server */
  new Image().src = loggerUrl + parameters;
};



Then create a lotusscript agent which gets the NotesSession.documentContext.query_string(0), filters the URL parameters out of it and saves the error information in a log or something else.

Custom component for printing all scoped variables


Declan Sciolla-Lynch posted a nice idea for this:

Create a custom component with a code like this:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:panel id="applicationVars" styleClass="debugPanel">
<xp:table styleClass="debug">
<xp:tr>
<th>Variable Name</th>
<th>Variable Content</th>
</xp:tr>
<xp:repeat id="varRepeat" rows="30" value="#{javascript:applicationScope.keySet();}" var="scopeData">
<xp:tr>
<xp:td>
<xp:text escape="true" id="varName" value="#{javascript:scopeData}" />
</xp:td>
<xp:td>
<xp:text escape="true" id="varValue" value="#{javascript:applicationScope.get(scopeData)}" />
</xp:td>
</xp:tr>
</xp:repeat>
</xp:table>
</xp:panel>
</xp:view>


Include the componet on your XPage and you will get a table with all applicationScope variables and their content. You can adapt this for sessionScope, viewScope, requestScope.

Debugging in the browser


Use Mozilla Firefox and install the Firebug and Web Developer extensions.

If you have to test on Internet Explorer, you can enable Firebug lite since Domion 8.5.1 as follows:

(see http://www.qtzar.com/blogs/qtzar.nsf/d6plinks/DSLH-7ZDN9A for details)

- use menu window -> show eclipse views -> other -> java/package explorer
- in the package explorer, navigate to WebContent/WEB-INF/xsp.properties
- edit the xsp.properties file and add the following line:

xsp.client.script.dojo.djConfig=isDebug:true


Don't forget to remove that setting when going into production!

Created by Anonymous on Sep 21, 2009 8:32:36 AM

RE: Error logging

Why use such a hack method of creating an image and setting it's URL when XPages is built on Dojo which has a built in handler for Ajax calls?

dojo.xhrGet() or something I believe is the call.


Add Comment

Name:
Comments:
Use  searchlotus.com  for news in the Web related to Lotus Notes and Domino,
and to search those sites.
Check  youatnotes.com  for great Lotus Notes, Domino and XPages software.
Did this information help you?
Please honor our efforts and flattr this!