Debugging application
In this Topic...
Related Topics ...
Overview: Debugging an Application
How to Use the Action List Builder
We can use debug tracing to track down bugs in an application. The Debug Tracing Builder allows you to trace variables and actions.
This builder writes trace information to a log file allowing you review the logged trace output after you have run a model. By default, this log file is located at:: <web_app_directory>\<project_name>\WEB-INF\logs\debugTracing.txt
Set log4j Debug Property
In order for debug tracing output to be written to the log file, the log4j.category.bowstreet.system.debugTracing property must be set to a value of "INFO" (default). Any setting for this property more lenient than "INFO" will also allow debug tracing messages to be logged. Any setting stricter than "INFO" will prevent messages from being logged.
The log4j.properties file should be located in your project's ..\WEB-INF\config\log4j.properties directory. Open this file and set the log4j.category.bowstreet.system.debugTracing property.
The log4j.properties file needs to be modified before you deploy an application. This file is read by the server when an instance of the model is run. Once the model is running we cannot change the properties file and see the changes in running model. To see the result of a property change shut down the server, save property changes, rebuild the project, deploy the project to the server and restart the server.
Trace the Value of a Variable
To trace a variable in a model, place a Debug Tracing Builder in the model. When you place this builder in a model, specify:
- Trace All Actions - Enable to ensure that the variable is traced through the entirety of the application.
- Additional Debug Output - Enter the name of the Variable you want the Builder trace.
Run the model and open debugTracing.txt to examine the log of your trace.
We can place multiple Debug Tracing Builders in a model if you want to trace the value of several Variables.
Trace a Specific Action
To trace a specific action in a model, place a Debug Tracing Builder in the model. When you place this builder in a model, specify:
- Trace All Actions - Disable to prevent tracing of all model actions.
- Action to Trace - Use the picker to select the method, page action, etc. you want to trace.
Run the model and open debugTracing.txt to examine the log of your trace.
Interpret a Debug Log File
After you run your application, open the debugTracing.txt log. It should look similar to the following:
This example log was created using the HelloWorld_Debug model and used the same inputs as the Trace a Variable section above. The upper portion of the log represents the actions that take place when the page first loads and can be interpreted as follows:
- Executing the main method took less than 20 milliseconds.
At that point in the application, the varHelloWorld variable was null.
- Executing the mainPage took 20 milliseconds.
At that point in the application, again, the varHelloWorld variable was null.
In the lower portion of the log, run at 12:47:08 am on September 3rd, the following can be interpreted:
- The Action button method took less than 1 millisecond to execute.
At that point in the application, the varHelloWorld variable was null.
- 2. The helloWorld method also took less than 1 millisecond to execute.
At that point in the application, again, the varHelloWorld variable was null.
- 3. To load the mainPage took less than 1 millisecond.
At that point in the application, the varHelloWorld variable was equal to "Hello, world".
Print Out the Value of a Variable
A common way to debug in Java is to use the System.out.println method. The Designer provides a similar tool we can use to generate a System.out.println statement. This tool is available from the Action List Builder. Here's how to use it:
- If you don t already have an Action List Builder in your model, add one.
- Add a new entry to your Action List by clicking on the "..." button to the right of the text box at the position you wish to add a debugging statement.
- In the Select an Action box expand the "Special" folder and select SystemOut.
- In the Set Argument box use the picker to drill down to the value you want to output, select it and click OK.
We can use the ActionList SystemOut argument to display the value of the same item multiple times throughout the ActionList. This allows you to trace an item's value through the entirety of program execution.
The value you display using SystemOut is displayed in the console and will look something like the following:
*--TIME: [2004-12-25] 16:07:05, 831] __*
Category: bowstreet.system.debugTracing
Priority: INFO
Msg: SystemOut= ${Variables/varHellowWorld} =null
As we can see, an entry was placed in the Action List to output the value of the varHelloWorld variable, and at this point in the program, it's value is null.
Tune for Performance
Applications created using Portlet Factory need to be architected for performance just as any other Java or web application would be and should be implemented using standard coding best practices as well as modeling best practices. Some of the factors that developers should be aware of when architecting for performance are:
* Memory usage - Minimize use of session data, large XML variables and other memory requirements)
* Performance of back end systems that are invoked
* Size of returned data
* Caching
* Sizing of the platform - Number and speed of CPUs
* JVM memory and performance settings
* Portal configuration
* Standard debugging and analysis techniques for the Server runtime environment
* All other development best practices of which you are awareWhile Portlet Factory makes it easy for non-architects to create complex portlets and applications, that does not replace the need for an architect or consultant to plan and review the application and deployment configuration to ensure good performance. Except for the way they are created, WPF Portlets and Portlet WAR's are the same as those created using hand-crafted or other development methodologies; they need the same considerations with respect to architecture and design, performance, debugging, testing and runtime analysis.