JBLogger -- JBuilder log file utility


Overview

JBLogger is a front end for JBuilder IDE that diverts JBuilder's output streams (System.out and System.err) to a user-specified log file.

It maintains multiple versions of the log file, automatically deleting the oldest log file when the configured number of log files has been reached.   The files are automatically renamed each time JBuilder is run.   So in a typical configuration, the log file for the current or most recent JBuilder session will be "JBuilder.log", the log file for the previous session will be "JBuilder-1.log", the one before that "JBuilder-2.log", etc.

Operation

JBLogger is just a simple java program that performs the following steps:
  1. Renames existing log files as described above.
  2. Uses the Java System.setOut() and System.setErr() methods to redirect the program output to the new log file.
  3. Transfers control to the main() method of JBuilder's main class.
In order for this to work, the JBLogger.jar file must be added to the class path, and JBLogger's main program must be run instead of JBuilder's main program.   See the
Installation section below for details on how to do this.

Configuration

The operation of JBLogger can be configured by setting a number of different Java system properties.   These will normally be set in the JBuilder.config file.

Property Name Default Value Description
JBLogger.logPrefix "../JBuilder" Defines the prefix for the log file name.   This may include a directory specification.   If a relative directory is specified, it will be resolved relative to JBuilder's "user.dir" directory, which normally is the JBuilder /bin directory.
JBLogger.logSuffix ".log" Defines the suffix for the log file name.
JBLogger.logSeparator "-" Defines the string that separates the prefix from the version number in renamed versions of the log file.
JBLogger.logCount 20 Specifies the number of log file versions to keep.
JBLogger.mainClass "com.borland.jbuilder.JBuilder" Specifies the class that JBLogger transfers control to after renaming and creating the log files and diverting output to the new log file.

Installation

First, copy JBLogger.jar to the JBuilder /lib/ext directory.   This will cause the JBuilder launcher to add the JAR file to JBuilder's class path.

Second, you must modify the "JBuilder.config" file in the JBuilder /bin directory.   Comment out the existing "mainclass" entry (which tells the launcher to run JBuilder's main class), and ad a new one that tells the launcher to run JBLogger.jar's main class. For example:

	#mainclass com.borland.jbuilder.JBuilder
	mainclass net.jpmcgrath.jblogger.JBLogger
Finally, use the "vmparam" option to specify properties to configure JBLogger.   For example:
	vmparam -DJBLogger.logPrefix=D:/Logs/JBuilder
	vmparam -DJBLogger.logCount=20

Questions

Questions or comments regarding this tool may be sent to JBLogger@JPMcGrath.net.


Copyright © 2000, John P. McGrath