I love Growl
. In my opinion it is something that should be built into the OS and I wish that every app supported sending Growl notifications. Lately I have been using Growl to get notifications from my own applications. This has been a great way to get instant feedback from applications while testing or when problems happen. However, instead of building in support for Growl, I add these notifications via a custom target for NLog so the notifications are configurable as part of the logging solution.
What is Growl for Windows?
First of all, for those who are not familiar with what Growl is, you're missing out. Take a look at Growl's About page
to find out more. Basically, it is a Windows version of the Mac growl notification system that displays notifications using the GNTP protocol. Growl gives you notifications when things happen. It can be something from your machine or something on some other machine on the network. Think of it as a uniform notification system that any application can use.
Using Growl as a Logging Notification Target
So, back to my original topic. I use NLog
for logging. For logging, NLog is awesome (why I prefer it to log4net will require another post). Some of the things that make Growl for a logging target useful for me:
The custom GrowlNotify target for NLog
- Instant feedback while testing applications. I can get details about what is going on in my application while testing, whether I am debugging or not by simply turning on my Growl target in the NLog.config file.
- If the application is running on a server, I can have the application send fatal or error logging notifications right to my desktop. If my server app has a fatal problem it will get logged, but I get the instant feedback with a Growl notification on my desktop.
Let's take a look at my simple custom NLog logging target for Growl. To use the GrowlNotify target in NLog, all you have to do is download the GrowlNotify binaries
, place them in the same folder as your app (no need to add them as references, just put them where the NLog.dll and NLog.config are), then wire it up as a target in the NLog.config file. Here is a sample configuration for using the GrowlNotify target:
<?xml version="1.0" encoding="utf-8" ?>
<add assembly="NLog.Targets.GrowlNotify" />
<target name="growl" type="GrowlNotify" password="" host="" port="" />
<logger name="*" minLevel="Trace" appendTo="growl"/>
That configuration will send any level of logging event to Growl on the same/local machine. To have the Growl notification sent over the network, all you have to do is fill in the parameters for "password", "host" (with a machine name or IP address), and optionally the "port" (if you've changed your Growl port from the default). That is it.
Each logging level has it's own icon. Here's some screenshots of NLog GrowlNotify in action:
Of course, once you've used GrowlNotify once and the DLL has registered itself with Growl, you'll be able to tweak things for each notification level in the Growl applications list, such as making the more critical levels play a different sound, etc: