HowTo-debug the applet (and get the debug ouput)?
The UploadPolicy contains a displayDebug method. This method :
- Displays the message on the status bar (on the bottom of the applet), if the current debugLevel is greater or equals to the level given to this method. To have no debug output, put this applet parameter to 0 ... or omit debugLevel, as 0 is the default level. 100 is the maximum debugLevel. As I didn't documente nor really manage the different values of this level... Let's say you may have 0 or 100 (debug off or on).
- Regardless of the log level, messages are always stored in a temporary log file (since version 2.9.2rc4). This file is named "jupload_xxxxx_log.txt" where xxxxx is a uniqe number and located in the platform-dependant temp directory. It is deleted upon VM exit.
The code contains a lot of calls to the displayDebug method. To retrieve the output generated by these calls:
- If you are in debug mode, you can copy the full status area, to get the recent lines of debug output. In order to save memory, the status area is limited to 1000 lines.
- If not in debug mode and the parameter urlToSendErrorTo is set, then - if a fatal error occurs - the user will be asked to submit the full log (from the log file). If she agrees, the applet will send the log to the specified URL using an HTTP POST. This allows you to log the error, send a mail to the webmaster or do whatever processing you want on the server side.
About the log format: The log lines contains several items, separated by a tabulation. This is very useful, as it is possible to isolate what a thread logged. The easiest way to open the debug output is, of course, to use a standard text editor. But it's also nice to use a tool like excel or openOffice, to view each item in a column, and be able to sort or filter entries. Here is the list of logged items:
- Id: A unique number, to easily sort the messages is the relevant order.
- Time: The time the event has been logged. Allows also to sort according to the message creation order, at one condition: that the display tool understand this format!
- Thread name: The name of the thread allows to filter (or sort) on the thread. It helps to understand what actually happens in one given thread. This is very interesting in picture mode, where picture are calculated while previous pictures are being uploaded.
- Level: ERROR, WARN, INFO or DEBUG. This level is controlled by using the UploadPolicy.displayXxx() relevant method.
- Message: the message itself.
There are two ways to do this:
- Change the server configuration: give the debugLevel applet parameter, in the applet tag. Put this parameter to 100, to get the full debug output.
- Change the applet configuration, once it is started (since 2.5). I've hidden this functionnality, to prevent user to activate this by error. Here is the way to activate the full debug output: Right-Click on the file list (since 2.9.0) or the status area, while holding the CTRL key down. This should open a popmenu: select the 'debug on' entry. Doing so switch the debug on and off. If the status area was hidden (with the showStatusBar applet parameter), it will become visiblen when debug is put on.