Saturday, October 23, 2010

Configure Java logging file handler

http://download.oracle.com/javase/6/docs/api/java/util/logging/package-summary.html


java.util.logging.config.file defines file used
by LogManager to configure root logger

FileHandler

%g the generation number to distinguish rotated logs

java.util.logging.FileHandler.count specifies how many output files to cycle through (defaults to 1).

http://www.linuxtopia.org/online_books/programming_books/thinking_in_java/TIJ317_021.htm

FileHandlers for non-root logger must be specified using Java.

FileHandler fh = null;
try {
fh = new FileHandler("dave." + System.getenv("serverName")+ "%g.log",
500000,
10
);
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

lgr2.addHandler(fh);