Thursday, February 26, 2009

Opera quick search

I have 3 browsers on my machine. Unfortunately not all of them are capable of working with all sites. Though I must admit that Opera has its own charm. I like the ability to quickly search my history.

To do so..

Type 'h' (without quotes) in the browser followed by the keyword and hit enter.

Opera will automatically list all your historical items matching the keyword.

Similarly for finding something on the current web page, you can use 'f'!

Wednesday, February 18, 2009

Log4j, Websphere - Print server or host name to application log

My project runs on Websphere server and uses a cluster of two servers. Both the servers log to the same application log file. After a bad production issue, we found it necessary to log the server name to the application log file, so as to be able to track activity on individual servers. Since the code is already in production, I didn't want to change it. Log4j documentation didnt help, and I didn't wish to dwelve into MDC.

Here is a simple trick that worked for me.

Websphere has an inbuilt variable WAS_SERVER_NAME, which basically has the name of the server (e.g. Server1, Server2 etc).

1. Using the Websphere Admin Console , I created a JVM Custom property.

Key = WAS_SERVER_NAME

Value = ${WAS_SERVER_NAME}

2. I referred the above property in my log4j.properties file.

log4j.appender.X.layout.conversionPattern=%d %-5p [%C] ${WAS_SERVER_NAME} %m%n

(The text in bold is the extra word that I added)

Now log4j prints the server name in the application log file.

This idea can be used to print any extra information, like host name etc!