Error handling


In its default behaviour jLo will not report any errors. This framework is designed in a secure matter that means that it should not crash any applications that it is used with. Therefore if no logger is found for example it will return a default logger rather then reporting an error. This makes error tracing inside jLo difficult. If you are sure that you have done everything right but still get the default logger and not the one you have defined then finding the error is hard. Therefore you can set a different error handler at runtime or even compile it if you want to have this as default.

At runtime

There are two ways to change the error handling at runtime.

system property

You can define a system property called jlo.errorhandler and define the error handler.
Here is an example that will set the ConsoleErrorReporter:
System.setProperty("jlo.errorhandler","org.jzonic.jlo.error.ConsoleErrorReporter");

properties file

You can also define the error handler inside a properties file called jlo.properties. Make sure you have this file in your classpath and put in the following line:
jlo.errorhandler=org.jzonic.jlo.error.ConsoleErrorReporter

Build it

First you need the source distribution of jLo. Then you must open the java class called ErrorHandlerFactory located in the src/org/jzonic/jlo/error directory. One of the first lines define the default error reporter. The default one is the so called NullDeviceErrorReporter. Change the line:
private static final ErrorReporter defaultReporter = new NullDeviceErrorReporter();
to this:
private static final ErrorReporter defaultReporter = new ConsoleErrorReporter();

Run ant and this jLo version will report any error to the console.