Chapter 3. Configuring Logging

If you set up logging according to the installation instructions and you just want to change logging level(s), then you don't need to read the rest of this chapter. To change the global logging level, just change the value of org.apache.commons.logging.simplelog.defaultlog in the file JAMAMA_HOME/localres/simplelog.properties. To change logging levels of particular components or areas, you do that in the same file. See the Commons Logging docs about the Simple Logger to find out how to make those settings.

Jamama users Apache Commons Logging. You can see the Commons Logging docs to learn anything you would want to know about how to configure it. In this chapter, I explain the default Jamama Commons Logging setup, and how to adjust Jamama to use log4j logging.

By default, you just rename the files in the localres directory according to the Jamama installation instructions. Commons Simple Logging will be used. At this time, I think that all you can do with Simple Logging is print to stderr (i.e., you can't log to files or anything, other than by OS shell redirection... and that's pretty inadequate for most purposes).

Java 1.4 Logging is supported by Commons Logging, but, in my opinion, it is just an inferior emulation of log4j.

There are other ways to set up log4j, I'm going to explain what I think is the most flexible and simple setup. There are three things you need to do.

Put your log4j configuration file into a directory in your classpath

The config file is named either log4j.xml or log4j.properties, and must reside directly in a classpath directory (i.e., not in a package directory or any other subdirectory).

Most users will just copy the file JAMAMA_HOME/localreslog4j.xml.sample file to log4j.xml and edit it. (localres will be in your classpath if you run Jamama as instructed in the User Guide).

Put a log4j jar file into your classpath

Just put the path to it into your classpath. Developers using Ant to start Jamama will need to set the property local.runtimeclasspath in JAMAMA_HOME/build.properties like

    local.runtimeclasspath: localres:/path/to/my/log4j-1.2.8.jar
Tell Commons Logging to use Log4j

Just change the value of property org.apache.commons.logging.Log in the file JAMAMA_HOME/localres/commons-logging.properties according to the instructions in the sample file (JAMAMA_HOME/localres/commons-logging.properties).

Create directory(s) needed by any file appenders

If you use the supplied log4j config file, just create the directory JAMAMA_HOME/log.