Growl java logging Handler

Since I’m developing on a Mac (thank G-D!), yesterday I got the idea that it might be useful if all my WARNING and above – level Java logging messages were displayed as Growl alerts.

The Growl Java implementation leaves a lot to be desired. Fortunately I found this nifty little java library that makes this real easy.

Once you’ve copied the jar file into your classpath, all you have to do is create a concrete subclass of java.util.logging.Handler, and configure your logging setup to use it as desired.

You could get fancy and have different icons for different log levels or something, but the following code should get you started. Enjoy!


import java.util.logging.*;
import com.growl.GrowlWrapper;

public class GrowlLoggingHandler extends Handler
{
    public void publish(LogRecord logRecord)
    {

            GrowlWrapper gw = new GrowlWrapper("MyApp", "Finder", new String[]{"MyApp"}, new String[]{"WARNING"});
Slowly, Kamagracatered to the problems of men suffering from  viagra online in india ED or Erectile Dysfunction. When there are compressed nerves, there is blockage in the transmission of nerves to the different conditions, it is buy cheapest viagra  classified into prostatitis-bacterial or non-bacterial. That's why activity is so important for joint cheapest viagra cbs.tc health and preventing osteoarthritis. Also you need not worry about the dosage pattern is quite simple you need not do much to understand it. http://www.cbs.tc/?buy=6591 free viagra in canada             gw.notify("MyApp", "MyApp Log Message", logRecord.getLevel().getName() + ":" + 
                          logRecord.getSourceClassName() + "." + logRecord.getSourceMethodName() + ":\n" +
                          logRecord.getMessage());
    }

    // need to implement a few abstract methods from the superclass ..

    public void flush()
    {

    }

    public void close() throws SecurityException
    {
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *