Friday, January 22, 2010

Tomcat 6 Logging

While the official Tomcat documentation states a clear departure from log4j and outlines the possibilities to still use it, I found myself looking for the quickest way to provide instructions to my team as to how to develop using tomcat.

We currently use JBoss in our servers but given the lack of J2EE in our current applications (Spring Framework based) it does not make sense to be waiting for 1 minute JBoss startup when tomcat offers two seconds response.

First when debugging locally it makes sense to see the server output in the console directly. True this can be done using the tail command and that is the way I prefer. Anyway do the below if you want to keep an eye on the server as soon as it is started

#exec "$PRGDIR"/"$EXECUTABLE" start "$@"
exec "$PRGDIR"/"$EXECUTABLE" run "$@"
Now let us make tomcat output our application traces. For that create or edit file at lib/log4j.properties

#### Use two appenders, one to log to console, another to log to a file
log4j.rootCategory=debug, stdout, R

#writes to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %5p [%t] (%F%L) - %m%n

#writes to a file. This is optional of course in a development environment
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${catalina.base}/logs/stdout.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %p %t %c - %m%n
#Archive logs
log4j.appender.R.MaxBackupIndex=10
#maximum log file size
log4j.appender.R.MaxFileSize=10000KB


From logs/stdout.log you can get all information you want and of course the same applies for the command line from where you started the server.

Be aware that your application must not have any log4j.properties file in the classpath otherwise you will end up overwriting the server configuration.

Saturday, January 16, 2010

Svn ChangeLog for Release Notes

While SVN does not come with a straight command to generate a ChangeLog latest versions come with an XSL that I have been using now for a while. I am just documenting it here as I found today my Ubuntu VM was missing the XSL file (svn2cl.xsl).

First be sure you have svn2cl in a known folder, I have picked ~/utils
cd ~/utils
wget "http://arthurdejong.org/svn2cl/svn2cl-0.12.tar.gz"
gunzip svn2cl-0.12.tar.gz
tar xvf svn2cl-0.12.tar
rm svn2cl-0.12.tar
 And now, everytime a ChangeLog is needed you can run a command like the below:

svn log --xml -r 7534:7548 --verbose "http://my.svn.domain/my-repo/my-project" |xsltproc ~/utils/svn2cl-0.12/svn2cl.xsl - > ChangeLog

In the above example I am obtaining a ChangeLog between two versions of my project (I got the interesting version numbers easy as I use Maven to release and so I get when Maven released last-7548 and when it released previously-7534)

Sunday, January 03, 2010

Local Temperature

I just released LocalTemp to the Android Market. Keeping it simple once again I came up with this application to show *just* the local temperature for the current location.

If you are accessing this page from an Android phone go ahead and click here to download.

Of course GPS functionality is needed and since I currently do not have an IPhone 3GS I will need to wait to release it to the IPhone App Store.

Please post any problems on this page.

Followers