Sidebar feeds

I did a minor blog re-design the other day.

Some cosmetic font tweaks and removal of a lot of the sidebar content.

I also added a left-hand sidebar (previously there was only one on the right).

This makes the content easier to read as the middle column is narrower and it also gives me an excuse to pull in content from Flickr and Twitter for the new sidebar.

Both Flickr and Twitter offer “badges” which give you a bunch of HTML and Javascript to put on your site and they then pull content in automatically.

They’re great but have one fundamental flaw – if Flickr or Twitter are down then they don’t work.

So, I’ve decided to adopt a more robust approach.

I’ve been pulling in links from my account to make a linkblog for a while so will follow a similar approach for Flickr and Twitter.

This post explains the theory behind it – the only new thing was the XSL stylesheets I used.

The Flickr stylesheet is fairly straightforward, it uses some CSS styles (below) to display the photos in two columns.

float: left;
clear: both;

The Twitter stylesheet is a little more complex.

It automatically filters out Twitter replies and strips the username from the text also.

Anyway, feel free to grab them for your own usage – leave feedback about them in the comments below.

Log4j with xml configuration

Like many Java developers, I use Log4j as my logging solution.

However, unlike many Java developers (in my experience anyway) I configure Log4j using xml rather than a properties file.

XML has always struck me as a neater way to represent what is essentially a hierarchical configuration.

However, it’s not terribly well documented (although the latest Log4j download comes with lots of example xml files).

Here’s an example entry from one of my xml files that sets up a daily rolling file appender appending to the existing file on startup.


<!-- An appender which writes to file -->
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="file" value="${user.home}/conf/apache/logs/boncey_app.log" />
<param name="datePattern" value="'.'yyyy-MM" />
<param name="append" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %C{6} (%F:%L) - %m%n"/>

Getting Tomcat to use a log4j XML file is a bit fiddly. The log4j manual explains how to set it up.

Under Tomcat 3.x and 4.x, you should place the under the WEB-INF/classes directory of your web-applications. Log4j will find the properties file and initialize itself. This is easy to do and it works.

However, it’s not immediately clear what to do if you use an XML file.

Dropping log4j.xml into WEB-INF/classes doesn’t work – or it didn’t for me on Tomcat 5.5.

Log4j manual to the rescue once more.

You can also choose to set the system property log4j.configuration before starting Tomcat. For Tomcat 3.x The TOMCAT_OPTS environment variable is used to set command line options. For Tomcat 4.0, set the CATALINA_OPTS environment variable instead of TOMCAT_OPTS.

So I put export CATALINA_OPTS="-Dlog4j.configuration=log4j.xml" into my shell startup scripts, dropped the log4j.xml file into my WEB-INF/classes dir and I was logging in no time!

One other thing you may find about log4j once you start using it is that lots of other Apache code uses it so once you set it up you’ll find your logs start filling up with lots (and I mean lots) of extra logging from the Apache code.

The traditional way to stop this is to add an entry as follows:

<category name="org.apache.tomcat" additivity="false">
<priority value="info" />
<appender-ref ref="FILE" />

This says that for anything logged from org.apache.tomcat, suppress anything less than INFO level, ie, suppress all DEBUG level logging.

The problem with this approach is that you have to keep adding new entries to suppress the logging from other packages too (Hibernate is a good example of this).

There is an alternative approach which is stunningly obvious once you hear it.

It is of course, better practice, to keep your application ROOT log level set to WARN or ERROR, and just turn on debugging for your own application classes! (ie. org.appfuse=DEBUG )

So obvious! Can’t believe I never thought of that.

So I set my base level to WARN then added “appenders” to log my own code at DEBUG level.

Voila, no more Tomcat cruft in my logs.

That concludes my ramblings on log4j and xml, hopefully they’ll be of use to someone (other than me of course).

delicious powered linkblog

I’ve added a linkblog to my site, it’s on the right-hand sidebar of my blog homepage.

The nice thing about this linkblog (for me) is that it’s automatically loaded from

To add something there I just add a URL to my bookmarks with a linkblog tag.

Within 30 minutes it appears on the blog here. Fully automated – nice.

The mechanism behind this is the same as the automatically updated Bloglines links further down the sidebar.

The only difference being the stylesheet as uses RDF and Bloglines uses OPML.

The other tweak I did in the stylesheet is to only show the ten newest links.

So, here’s the stylesheet that I made if it’s useful to anyone.