RSS 2.0 Feed
RSS 2.0


Atom 1.0 Feed
Atom 1.0

  Announcing the Growl for Windows Target for NLog (and another reason to love Growl) 


qt8gt0bxhw|20009F4EEE83|RyanMain|subtext_Content|Text|0xfbff385d02000000ab00000001000600
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:
  1. 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.
  2. 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.
The custom GrowlNotify target for NLog

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" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<extensions>
<add assembly="NLog.Targets.GrowlNotify" />
</extensions>

<targets>
<target name="growl" type="GrowlNotify" password="" host="" port="" />
</targets>

<rules>
<logger name="*" minLevel="Trace" appendTo="growl"/>
</rules>

</nlog>

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:






                   



Leave a comment below.

Comments

  1. Arthur 5/7/2010 9:08 PM
    Gravatar
    Cool post Ryan thank you,

    this combination opens a whole new world of collaboration capabilities!
  2. João Almeida 5/10/2010 6:36 AM
    Gravatar
    Totally agree, Windows, like OSX or Linux, should have a unified notification system (although I still prefer Snarl's look and feel over Growl), and this little extension is a fine example of all the cool things we could have available.
  3. vyas 6/28/2010 3:17 AM
    Gravatar
    Hi Ryan ,

    Can you explain or put in a sample code in brief like how to use Growl in NLog configuration.


    Thanks in advance,
    Vyas
  4. Jonathan Stanton 6/29/2010 3:52 PM
    Gravatar
    Hi there, Thanks for this but I am having problems when trying to load the extention. I keep getting the exception "System.ArgumentException: Target GrowlNotify not found." when I create an instant of a logger. The nlog framework is working as it logs when I don't use the growl extention.

    I am using dotNet 4 (I don't know if that is a known issue).

    Any suggestions what might be causing this

    Many thanks

    Jonathan
  5. Ryan Farley 7/5/2010 12:43 PM
    Gravatar
    vyas, The github repo has a demo app you can try to see a sample config file and sample code.

    Jonathan, I can use this just fine with .NET 4 framework. It is likely the placement of the DLL that is the problem. I'll reply on the github issue with further details http://github.com/RyanFarley/NLogGrowlNotify/issues#issue/1
  6. Jonathan Stanton 7/19/2010 2:35 AM
    Gravatar
    Thanks. I traced the problem down to me using the wrong version of NLog. I was using the Stable V1 release not the Beta V2 version.
  7. Ryan Farley 7/19/2010 9:06 AM
    Gravatar
    Thanks for letting me know Jonathan.
  8. Marcelo 3/3/2011 7:17 AM
    Gravatar
    (sorry for my bad english)

    I have problems with version 2.0 of nlog
    The file nLog.config does not understand the definition

    <target name="growl" type="GrowlNotify" password="" host="" port="" />

    Can you help me.
    Tnks in advance.
  9. Mac Keylogger 3/20/2011 10:36 PM
    Gravatar

    yea, it opens a whole new world of collaboration capabilities.
  10. Mac Keylogger 3/20/2011 10:38 PM
    Gravatar
    Mac keylogger
    yea, it opens a whole new world of collaboration capabilities.
  11. bhavna 3/27/2011 9:31 PM
    Gravatar
    online casinos
    I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities have inspired me a lot

  12. Eddie Chen 4/8/2011 5:49 AM
    Gravatar
    This is a great project. I tried to use this on a test ASP.NET web application and found out a problem that is related to the nLog data type conversion issue. The error message I got was "Input string was not in a correct format."

    In order to use it in a web app. We need to change the config as the following. Change port = "" to port = "0". This is because in nLog, it will try to convert the type of the port to int32 and when we supplies an empty string, it will generate the error.

    <targets>
    <target name="growl" type="GrowlNotify" password="" host="" port="0" />
    </targets>
  13. Power Balance 6/13/2011 7:04 AM
    Gravatar
    I was very pleased to find this site. I wanted to thank you for this great read I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.
  14. Card Counting 7/16/2011 10:05 PM
    Gravatar
    It’s good to see this information in your post,, i was looking the same but there was not and proper resource,thanks now i have the link which I was looking for my reseach.
  15. Olugbenga Omoni 7/28/2011 6:21 AM
    Gravatar
    Nice reading this, tried to implement and got this error

    Error when setting property 'Port' on GrowlNotify Target (Using Nlog2.0)

    Already set the configuration as below

    <target name="growl"
    type="GrowlNotify"
    password=""
    host=""
    port="0" />
    </target>

    Thanks
  16. log baskets 9/4/2011 6:26 AM
    Gravatar
    This is excellent, thanks for giving so much detail and pictures too!! I wasn't sure if i wanted to get growl cause it looked complicated but you really simplified it here :) thanks!!
  17. Laurent 10/7/2011 10:18 AM
    Gravatar
    Hi,
    Does it work with NLog 2.0? I'm having issues setting that up? Is anyone using it successfully?

    Thanks
  18. Car Auctions Sydney 10/8/2011 6:03 AM
    Gravatar
    I'm also having the same issue with growl.. but this post help me through it. thanks
  19. social media consulting 10/11/2011 11:37 PM
    Gravatar
    Hi Ryan, this is such a good post......thanks for sharing with us.
Comments have been closed on this topic.



 

News


Also see my CRM Developer blog

Connect:   @ryanfarley@mastodon.social

         

Sponsor

Sections