This package provides the means for the creation and dispatch of log messages. It is independent of all other qflib packages, so it can be packaged into its own jar and installed seperately, e.g. to reduce download time for applets. It doesn't even depend on the collections package so it can be used from JDK 1.1 Applets without the need for the collections.jar

Logging is especially useful during development and testing since it is an invaluable debugging aid, but also during production runs, where a certain amount of logging is often needed to supervise a program.

There are a few things that have to be considered to get the most out of logging:

All of the above and a little bit more is adressed in the {@link de.qfs.lib.log.Log Log} and the {@link de.qfs.lib.log.Logger Logger} classes.

The Logger class is responsible for generating log messages as well as for suppressing that generation, while the Log class is responsible for filtering and dispatching log messages.

Log messages can be redirected to a log file with the help of the {@link de.qfs.lib.log.FileLogWriter FileLogWriter} class or sent to a separate LogServer process with a {@link de.qfs.lib.logrmi.RemoteLogWriter RemoteLogWriter}.

Typical use of the log package looks like this:

import de.qfs.lib.Log;
import de.qfs.lib.Logger;

class SomeClass
{
    // Initialize the logger for SomeClass
    private final static Logger logger = new Logger (SomeClass.class);


    public void someMethod(int someParameter)
    {
        // log entry to the method, optionally with parameters
        if (logger.level >= Log.MTD) {
	    logger.log(Log.MTD, "someMethod(int)",
	               logger.level < Log.MTDDETAIL ? "" :
		       "someParameter: " + someParameter);
        }
	...

	// some debugging output
        if (logger.level >= Log.DBG) {
	    logger.log(Log.DBG, "someMethod(int)",
                       "Some debug message");
        }
	...

	try {
	    // do something dangerous
	    ...

	} catch (BadException ex) {
	    // log exception at error level
	    if (logger.level >= Log.ERR) {
		logger.log("someMethod(int)", ex);
	    }
	} catch (NotSoBadException ex) {
	    // log exception at warning level
	    if (logger.level >= Log.WRN) {
		logger.log(Log.WRN, "someMethod(int)", ex);
	    }
	}
    }
}
While the above may look overly complicated, it's not that bad if you consider the benefits: With the use of the remote log server qflog, log messages can be viewed, sorted, filtered etc., and the levels of the Loggers relevant for the creation of the messages can be tuned at runtime.