Code-level documentation is useful when implementing new features. For debugging, we will now use a logging system. I have implemented my own extension of Log4j.
Create a runtime.properties file in JP's root directory
##################################################################
# #
# Logging #
# See Log4j information on formatting this section #
# #
##################################################################
# Define the appenders
log4j.rootCategory=TRACE, Default, Console, html, SYSLOG
# set to true to enable log4j debugging
log4j.debug=false
#
# Default appender to file log/server.log
#
log4j.appender.Default=org.apache.log4j.RollingFileAppender
log4j.appender.Default.Threshold=TRACE
log4j.appender.Default.File = build/log/server.log
log4j.appender.Default.layout=org.apache.log4j.PatternLayout
log4j.appender.Default.layout.ConversionPattern=%d %c{1} [%p] %x - %m%n
# Do not Truncate if it aleady exists.
log4j.appender.Default.Append=true
log4j.appender.Default.MaxFileSize=1500KB
# Archive log files (one backup file here)
log4j.appender.Default.MaxBackupIndex=10
#
# The console appender
#
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Threshold=INFO
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d %c{1} [%p] %x - %m%n
#log4j.appender.Console.layout.ConversionPattern=%d (${dbUserId}) %c{1} [%p] %x - %m%n
#
# HTML appender properties
#
log4j.appender.html=org.apache.log4j.RollingFileAppender
log4j.appender.html.Threshold=DEBUG
log4j.appender.html.File=build/log/index.html
log4j.appender.html.layout=org.apache.log4j.HTMLLayout
#
# Syslog appender
#
log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender
log4j.appender.SYSLOG.SyslogHost=192.168.1.30
log4j.appender.SYSLOG.Facility=USER
log4j.appender.SYSLOG.FacilityPrinting=true
log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout
log4j.appender.SYSLOG.layout.ConversionPattern=%t %5r %-5p %-21d{yyyyMMdd [HH]mm:ss,SSS} %c{2} [%x] %m %n
# #
# Logging #
# See Log4j information on formatting this section #
# #
##################################################################
# Define the appenders
log4j.rootCategory=TRACE, Default, Console, html, SYSLOG
# set to true to enable log4j debugging
log4j.debug=false
#
# Default appender to file log/server.log
#
log4j.appender.Default=org.apache.log4j.RollingFileAppender
log4j.appender.Default.Threshold=TRACE
log4j.appender.Default.File = build/log/server.log
log4j.appender.Default.layout=org.apache.log4j.PatternLayout
log4j.appender.Default.layout.ConversionPattern=%d %c{1} [%p] %x - %m%n
# Do not Truncate if it aleady exists.
log4j.appender.Default.Append=true
log4j.appender.Default.MaxFileSize=1500KB
# Archive log files (one backup file here)
log4j.appender.Default.MaxBackupIndex=10
#
# The console appender
#
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Threshold=INFO
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d %c{1} [%p] %x - %m%n
#log4j.appender.Console.layout.ConversionPattern=%d (${dbUserId}) %c{1} [%p] %x - %m%n
#
# HTML appender properties
#
log4j.appender.html=org.apache.log4j.RollingFileAppender
log4j.appender.html.Threshold=DEBUG
log4j.appender.html.File=build/log/index.html
log4j.appender.html.layout=org.apache.log4j.HTMLLayout
#
# Syslog appender
#
log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender
log4j.appender.SYSLOG.SyslogHost=192.168.1.30
log4j.appender.SYSLOG.Facility=USER
log4j.appender.SYSLOG.FacilityPrinting=true
log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout
log4j.appender.SYSLOG.layout.ConversionPattern=%t %5r %-5p %-21d{yyyyMMdd [HH]mm:ss,SSS} %c{2} [%x] %m %n
Now add a few log.trace("comment here"); statements throughout your code.
> ant junit
Now check in build/log for a log file with all TRACE messages (and higher) and an html file with DEBUG messages (and higher). There is also INFO (and higher) messages going to the console (like during ant builds) and DEBUG (and higher) going to a remote syslog server, if available.
> ant clean
and notice that the log directory remains
> ant svn
commit
Logging