Logging
An administrator needs to confirm correct operation of a server and track down problems as they occur. webMathematica helps by providing a variety of different types of logging systems.
webMathematica Logging
webMathematica provides a flexible logging system that allows you to learn about the running of your server. This can be useful as a way to track down errors. The system is built on top of the popular log4j logging services. The system is configured with files loaded when the server launches, and can record different levels of event, FATAL, ERROR, WARN, INFO, DEBUG, and TRACE, ranging from serious to not serious.
Configuration for the webMathematica logging system is found in the file log4j.properties located in webMathematica/WEB-INF/classes. The default provides three loggers, which collect different types of log information. By default, logging only records events that are at level INFO and above. Output for all the loggers goes into <path-to-tomcat>/logs.
webMathematica.log | core webMathematica log file |
KernelEvents.log | kernel events, such as evaluations, messages, and print output |
JobEvents.log | logging for jobs that support queues |
Default webMathematica log files.
The core webMathematica log file is the core main logger that records many different types of event. The request log file contains logging for each request, and is a simple way to see activity to the site. The kernel log file shows information about how the kernel is used. In particular, it contains message output (at the WARN level) and print output (at the INFO level).
The folder webMathematica/WEB-INF/classes/samples contains a sample logging configuration file, log4j.properties.DEBUG, which turns on logging at the DEBUG level. It also contains log4j.properties-sample, a logging file with more comments, and the original file, log4j.properties.BACK. To activate one of these, copy it to webMathematica/WEB-INF/classes, rename it to log4j.properties, and restart the server. The log files will collect information at the new level. This might be a good way to track down problems in your webMathematica server.
To configure the logging system at more detail, you could study log4j.properties-sample; then you should probably consult one of the many references that exist for log4j.
Server Logging
One key place to search for information on problems is the server logging system. Under Tomcat, typical logging files are <path-to-tomcat>/logs/localhost_log.YYYY-MM-DD.txt, where the filename includes the date. For other servlet containers you will need to study the relevant documentation. If the log file is empty, it may indicate that the user running the servlet container does not have permission to write to the log file directory.
The log file records serious errors; if your system does not function correctly at startup time, it would be good to look here. For example, if the configuration file is not found or the kernel cannot be launched, this will be recorded in the log file. Later, if there is a serious error that requires shutting down a kernel, this is also recorded.
Note that the server logs do not show webMathematica specific logging. This comes in the webMathematica logging system.
The Kernel Monitor
The kernel monitor is a servlet that collects information on the running of your site. You should be able to find the monitor via the URL http://localhost:8080/webMathematica/Resources/Tools/KernelMonitor.jsp. (You may have some different URL for accessing your server.) Upon access, the monitor brings up a page showing the current status of webMathematica, describing various parameters of the site, and giving status information for each kernel. If you look at this page, access some JSPs, and then look at the page again, you should see updates, such as a change in the number of times kernels have been accessed.
For security purposes it would be sensible to restrict access to the kernel monitor. If the servlet engine is accessed via an Apache web server, access can be restricted in the server configuration files. The section on Apache and Tomcat describes how this can be done.