A handy debugging technique available to any OFBiz Java programmer at any time is to write messages to the OFBiz console log from within your program.
Firstly, ensure the following:
org.ofbiz.base.util.Debug
utility into your Java program. module
is defined within your class file as shown below:public static final String module = MyClass.class.getName();
To always write to the console window, call the OFBiz Debug utility as shown:
import org.ofbiz.base.util.Debug; // Code intentionally left out Debug.log("This is an error message", module); //Or, if you don't want to write to using the Logger System.out.println("This is an error message");
A call to the org.ofbiz.base.util.Debug
method as shown earlier will always write a message to both the error logfile, ofbiz.log
and the console window, if it is open.
To write log messages under other conditions, consult the log4J settings and pick the appropriate Debug
utility method. For example, to write to the logfile and/or console window only when "Fatal" messages are turned on, you might have a statement such as the following in your code:
Debug.logFatal("Some message", module);
The OFBiz logging facility is an integration of the Apache log4J Java program logging toolkit: http://logging.apache.org/log4j/.
Toggling log settings, that is turning them on or off, is easily accomplished using the WebTools Logging tab, Log Configuration utility.
52.15.176.80