How do I use the Jaxer logging system to log messages?

The Jaxer framework includes a logging system, and is itself liberally instrumented with logging statements. The Jaxer logging framework is similar to log4j and other multi-level, multi-module logging systems. Briefly, you can instrument your code with logging statements at various levels, and if the current logging level is at or below a statement's level the statement will write to the log.

The six levels are, in increasing weight: trace, debug, info, warn, error, and fatal. By default, all modules (including the generic module) are set to log all messages at or above info.

To use the generic logging module (i.e. log messages that aren't specific to any module), use the static methods off Jaxer.Log:

Normally you will only see the last 4 of these produce anything in the log, since the first two are below the default level of info. You can change that, e.g. in the Jaxer shell, or in your local_jaxer/configLog.js where you can see one or more or even all the modules to log at a lower level. Try Jaxer.Log.forModule("DB").setLevel(Jaxer.Log.TRACE); or Jaxer.Log.setAllModuleLevels(Jaxer.Log.INFO); and note that the levels themselves are indicated by the all-caps constants.

It's better to create your own module-specific loggers, because then you can selectively turn on logging for different parts of your code. It's very easy: e.g. You can use any name you want for your modules. Whenever you use a name that has not been used before, a new module logger is created for you, and you get back a handle to it, as shown above. If you use one that's already been used, you just get back a handle to that one.

Note also that by default any log messages at or above the Jaxer.Log.ERROR level will automatically also contain a stack trace. As usual, you can control that through configLog.js.