Logging Suite User's Guide

Welcome to the RP Logging user's guide. RP Logging is a simple logging mechanism written entirely in Java using the java.io package. It includes the following options:

  • File creation based on a given time period. RP Logging will automatically create new dated files per time period set up in the configuration. For example, RP Logging can be set up to generate a new log file every day.

  • Logging levels. RP Logging has various logging levels. RP Logging will decide whether to physically write to the log based on the logging level set up in the configuration and the method of the Logging class called by the user.

  • Single and Multi-threaded implementations. The single threaded logger, com.rp.log.RpLogger, does all IO writes in the current thread. The multi-threaded logger, com.rp.log.MTRpLogger, does all IO writes in a separate thread.

INSTALLATION:

The RP Logging download is via a zip file with a name similar to rpLog.zip. The name will also include a version number, i.e. rpLogging1_2.zip. This corresponds to version 1.2. This zip file contains a jar file named rpLogging1_2.jar that contains both the source and the class files. To install RP Logging, note the following:

  • If using RP Logging in a web application

    Simply copy the rpLogging1_2.jar file into your web application's WEB-INF/lib/ directory or copy the rpLogging1_2.jar file to a directory on the machine running the web application and include a reference to rpLogging1_2.jar in the system classpath.

  • If using RP Logging in a java application

    Copy the rpLogging1_2.jar file to a directory on the machine running the application. Then modify the classpath of that machine to include a reference to the jar. For example, on a Windows machine this can be accomplished as follows (assuming rpLogging1_2.jar is copied to c:\classes):

    set CLASSPATH=c:\classes\rpLogging1_2.jar;%CLASSPATH%

  • If using RP Logging in a situation where the classpath cannot be modified:

    Extract the files from rpLogging1_2.jar and copy them to a directory already inlcuded in the classpath.

CONFIGURATION:

Listed below is a test class called TestLog.java that illustrates how to use RP Logging. NOTE: In a normal application, you would maintain only one instance of the logger in memory.

import com.rp.log.*;
import java.io.*;

public class TestLog
{
    public static void main (String[] args)
    {
        try
        {
            RpLogger logger = new RpLogger("test.log", RpLogger.DEBUG, RpLogger.DAILY);
            logger.debug("debug hello");
            logger.info ("info hello");
            logger.warn ("warn hello");
            logger.error ("error hello");
            logger.fatal ("fatal hello");
            
            MTRpLogger mtLogger = new MTRpLogger ("mtTest.log", MTRpLogger.DEBUG, MTRpLogger.DAILY);
            mtLogger.debug("debug from mt");
            
            logger.destroy();
            mtLogger.destroy();
        }
        catch (IOException e)
        {
            e.printStackTrace();    
        }            
        catch (Exception e)
        {
            e.printStackTrace();    
        }
    }    
}