Thursday, February 5, 2009

Logging

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


private Log logger = LogFactory.getLog(Class.class);


# Custom API
log4j.appender.custom=org.apache.log4j.RollingFileAppender
log4j.appender.custom.File=@log_path_custom@
log4j.appender.custom.MaxFileSize=50MB
# Keep three backup files.
log4j.appender.custom.MaxBackupIndex=3
# Pattern to output: date priority [category] {TH thread}- message
log4j.appender.custom.layout=org.apache.log4j.PatternLayout
log4j.appender.custom.layout.ConversionPattern=%d %p [%c] {TH %t} - %m%n
# Categories
log4j.logger.com.penton=debug,custom

Advantage of a scripting language

I can drop the script into a client environment and run it without having to build. This could be useful in debugging production issues.