Helma Logo
main list history
previous version  overview  next version

Version 8 by earl on 25. September 2009, 03:37

The *helma.logging module|http://github.com/hns/helma-ng/blob/master/modules/helma/logging.js* provides logging functionality using *Apache log4j|http://logging.apache.org/log4j/1.2/index.html*.

helma.logging can be configured by passing a log4j XML or properties configuration file to the setConfig() method. The default configuration is file *modules/config/log4j.properties|http://github.com/hns/helma-ng/blob/master/modules/config/log4j.properties*.

Helma provides a special Appender class called org.helma.util.RhinoAppender that allows to send log messages to a Javascript *callback* function. The logging module provides the methods enableResponseLog() and disableResponseLog() to enable and disable appending of RhinoAppender log messages to a response buffer, using similar formatting as res.debug in Helma 1.

  var log = helma.logging.getLogger(__name__);

Then the following code ...

    log.info("Hello world!");
    try {
    } catch (e) {
        log.error(e, e.rhinoException);

... will produce the following output on the rendered page:

<div class="helma-debug-line" style="background: #fc3; color: black; border-top: 1px solid black;">3300 [pool-1-thread-2] INFO  modulename  - Hello world!
<div class="helma-debug-line" style="background: #fc3; color: black; border-top: 1px solid black;">3303 [pool-1-thread-2] ERROR modulename  - ReferenceError: "foo" is not defined.
<h4 style='padding-left: 8px; margin: 4px;'>Script Stack</h4>
<javascript stack trace>
<h4 style='padding-left: 8px; margin: 4px;'>Java Stack</h4>
<java stack trace>