Helma logo
helma.org » Home > development > rfc > Logger Interface / log4j

Logger Interface / log4j

DEPRECATED - see Logging interface (2nd run)

It should be possible to set the logger (i.e. logger factory) used for logging within Helma. The logger factory should be set either server-wide in the server.properties and/or per application in the app.properties file.

Example:

loggerFactory = helma.util.DefaultLoggerFactory
loggerFactory = at.knallgrau.helma.log4j.LoggerFactory
...
Doing so it would be possible to write wrapper classes for prefered loggers like log4j, the logger we intend to use here at Knallgrau in the future.

When looking deeper into Helma Source one finds a lot of debugging log messages that are just commented out, but could be extremly useful information for Helma Developers. Because of this fact and the need for most other Loggers I'd suggest to implement the logger interface with the use of log levels. For the default helma logger, the minimum required log levels should be set like the logger factory (e.g. server-wide and/or overruling per application) - other loggers like log4j use their own config file anyway.

Example:
loggerLevel = INFO
These log levels should and must of course apply to the JS envoirement too, thats why we need to extend the app.log() function. Therefore I'd suggest to add a logger Object to the application Object.

Example:
app.logger.log("Logging message");  
/* log a message to the default log with a default log level (should be INFO) */

app.log("Logging message"); 
/* the same as app.logger.log(), kept for backwards compatibility */

aoo.logger.log("Logging message","info"); 
/* log a message to the info log with default log
level, where info would be a seperate file when using
the helma default logger, when using log4j it would be
the log category */

app.logger.log("Logging message","access",app.logger.FATAL); 
/* log a message to the access log with log level FATAL */

app.logger.log("Logging message","",app.logger.INFO);
/* log a message to the default log (which is event
when using the helma default logger) with log level
INFO */
To sum it up, the documentation for the new app.logger object would look like this:
void logger.log(String message)
void logger.log(String message, String category)
void logger.log(String message, String category, int logLevel)
int logger.DEBUG
int logger.INFO
int logger.WARN
int logger.ERROR
int logger.FATAL
These explicit log levels are taken from log4j, but although I am sure they fullfill all needs, it would be absolutely no problem to add new / others.

I've already patched Helma 1.2.6 and uploaded a pre-compiled helma.jar. Anybody who wants to give it a try or look at the possibilities using log4j with the logger interface should continue reading here: http://helma.org/stories/77540

I will try to cleanup the source of the logger interface implementation and post the patches to the mailing list within the next days.


Up: Requests For Comments (RFCs)
Previous: Making Macros more Component-like in Helma 2.0 Next: Logging interface (2nd run)

... comment


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