Helma logo
helma.org » Home > development > rfc > Logging interface (2nd run)

Logging interface (2nd run)

IMPLEMENTED - Informations on this page might be out of sync with actual implementation
Helma extended with the Apache Commons Logging interface offers a bright new world of logging possibilites.

This is more than just a RFC - right now, everything is done and prepared, sit back,relax and enjoy the flight into the future of logging (-;

I extended Helma with the Apache Commons Logging interface, to have the possibility to choose amongst different logging systems.

Example:

# this is the default, its the well known Helma logger 
# extended to fit the logging interface
loggerFactory = helma.util.LoggerFactory
# log4J for Helma / the Apache Commons Logging interface
loggerFactory=org.apache.commons.logging.impl.LogFactoryImpl
...
As you can see, Apache Commons Logging already offers some implementations for it's interface - e.g. to use log4J - and there is of course an implementation for the default helma logger, as we know it.

Lets first sum up what changes for the default behaviour of logging before going into detail.
  • Helma Logger remains the default logger if there is no other value set for the loggerFactory property in the server.properties
  • The logDir property can only be set server-wide in the server.properties file and it is only used for the default logger
  • The server log file is renamed to helma.server.log
  • Access and Event log files are renamed to helma.appName.access.log / helma.appName.event.log
If you decide to use a logging system different to the default logger, these are also the names Helma uses to get loggers from the set LoggerFactory.
helma.server
helma.appName.event
helma.appName.access
helma.appName.userDefined
helma.appName.userDefined would be the name of the logger Helma uses for logging events that where triggered using
app.log("my message", "userDefined");
within the scrippting envoirement.

There is something that still has to be done: The Apache Commons Logging interface requires (as almost any other logging system does) to log events using priorities / levels. So far everything coming from the scripting envoirement is logged with priority INFO, all logging events within Helma have been rewritten to use the logging level they need.
Logging within the scripting envoirement should be extended like this to use the possibilites of the new logging interface:
# log level INFO, kept for backwards compatibility
app.log(message);

app.trace(message);
app.trace(message, exception);
app.debug(message);
app.debug(message, exception);
app.info(message);
app.info(message, exception);
app.warn(message);
app.warn(message, exception);
app.error(message);
app.error(message, exception);
app.fatal(message);
app.fatal(message, exception);
Basically, thats it. So right now as you can't wait anymore to try the new logging possibilites, i'll tell you what you have to do to actually use them.

Get yourself an up-to-date checkout of Helma 1.2.6 from the CVS repository (yeah, its only implemented for 1.2.6 yet for practical reasons, but as far as I can see now, it only needs some additional hours to adopt it for 1.3.x too).
Then download the changes [HopMacro error in file: java.lang.RuntimeException: Error retrieving Node: java.sql.SQLException: General error message from server: "Can't open file: 'AV_FILE.MYI' (errno: 145)"] to the source, place them in the right directories and compile Helma.
Download the jar files needed for Apache Commons Logging (which are commons-logging.jar and commons-logging-api.jar, download them from here: http://apache.netmonic.com/jakarta/commons/logging/binaries/commons-logging-1.0.3.zip ) and place them in your lib/ext directory.

You should now have a future logging enabled version of Helma, just start it and you should at least already see the changes to the file names in your log directory.

Next step is to combine Helma with a logging system like log4J, read more: http://helma.org/stories/77549 !


Up: Requests For Comments (RFCs)
Previous: Logger Interface / log4j Next: Application Modules

... comment


Page last modified on 2007-10-23 13:08 by daniel