Sidebar

How can I enable logging for a QIE form?

+1 vote
833 views
asked Jul 23, 2014 by mike-r-7535 (13,830 points)
I often want to debug my code within a QIE form.  Is there a way to log messages from within the context of a form?

4 Answers

+1 vote
 
Best answer
The traditional logging statements of a channel (qie.info(), qie.warn(), etc...) do not work within the context of a form.
 
However, QIE uses log4j, which can be tapped into.  To do so, try the following:
 
var logger = org.apache.log4j.Logger.getLogger("My_Form_Script_Logging");
logger.warn("I can log my output statements within a form!!!!");
 
You will then find your log statements in your qie.log file.
answered Jul 23, 2014 by mike-r-7535 (13,830 points)
commented Jan 28, 2020 by rich-c-2789 (16,180 points)
Starting with version .49 the logger was updated from log4j1.x to log4j2.x.  So, after this version use:

var logger = org.apache.logging.log4j.LogManager.getLogger("My_Form_Script_Logging");
logger.warn("I can log my output statements within a form!!!!");
0 votes
To place a "flashlight" in the form load script, you can enable a text area field on the form:
<tr>
  <td align="center" style="vertical-align: middle;">
    <widget id="temp" type="textArea" height="200" />
  </td>
</tr>
and then populate it in the form load script as follows:
fieldData.put('temp', 'I can display relevant information in this text area');
answered Mar 25, 2015 by ron-s-6919 (4,480 points)
0 votes

A quick and easy way to place a "flashlight" in the form load script is to use an error message.  There are 2 different ways of doing this.

The first way is to use the forms built in failure message as follows:
fieldData.put("failureMessage", 'I can return an error message to the user.');
fieldData.put("redirectOnFailure", "true");
return;
This produces a message that looks like this:
 
 
When the "Ok" button is pressed, the form then closes.
 
The second way is to use a JavaScript throw statement as follows:
throw 'I can throw an error in the script.';
This produces a message that looks like this:
 
 
In this case, when the "Ok" button is pressed, the form is not closed.
 
With both of these options, displaying a large amount of data, or structured data like XML does not work very well and using another method will usually work better.

 

answered Mar 25, 2015 by ron-s-6919 (4,480 points)
0 votes

Here is another option, but it requires the use of a channel.  Setup a channel as a listening webservice, create a webservice connection, and wrap the call to the webservice in a published function called "callLogger".  You can then call the logging service with the following call:

callLogger("This is a test log message from a form");

Here is a link to the configuration: https://www.qvera.com/kb/?qa=blob&qa_blobid=8627679385102658782

answered Jul 8, 2015 by mike-r-7535 (13,830 points)
...