Helma Logo
main list history
previous version  overview  next version

Version 10 by hannes on 25. September 2009, 18:23

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.

    import('helma/logging');
    var log = helma.logging.getLogger(__name__);getLogger(module.id);

Then the following code ...

    log.info("Hello world!");
    try {
        foo.bar;
    } 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>
<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>
<i>javascript stack trace</i>
<h4 style='padding-left: 8px; margin: 4px;'>Java Stack</h4>
<i>java stack trace</i>
</div>

     removed
     added