Helma Logo
main list history
previous version  overview  next version

Version 9 by earl on 25. September 2009, 03:40

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

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

Helma provides a special Appender class called org`org.helma.util.RhinoAppender RhinoAppender` that allows to send log messages to a Javascript *callback* function.

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

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>
<javascript <i>javascript stack trace>trace</i>
<h4 style='padding-left: 8px; margin: 4px;'>Java Stack</h4>
<java <i>java stack trace>trace</i>
</div>

     removed
     added