Search code examples
c#nloggrowl

Breaking changes in NLog 3 when trynig to integrate with growl


I was trying to test integration of NLog & Growl as per this article.

Here's the NLog config file:

<?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">

    <!-- This is for Growl -->
    <extensions>
        <add assembly="NLog.Targets.GrowlNotify" />
    </extensions>

    <targets>
        <!-- This is for testing , output to console -->
        <target  xsi:type="ColoredConsole"
                    name="console"
                    layout="${shortdate} ${level} ${message}" />

        <!-- This is for Growl -->
        <target name="growl"  xsi:type="GrowlNotify" 
                password="" host="" port="" />
    </targets>

    <rules>
        <!-- This is for testing , output to console -->
        <logger name="*"
                minlevel="Trace"
                writeTo="console" />

        <!-- This is for Growl -->
        <logger name="*" 
                minlevel="Trace" 
                writeTo="growl"/>
    </rules>
</nlog> 

The result are: Nothing being logged (not to growl, nor to the console).

Removing the growl target and rule, and it logs happily to the console (and other targets I have as well).

To cut a short story long:

  • Nlog home page suggests NLog 3 will be released sometimes soon (this was written there over half a year ago)
  • Using Nuget to install NLog will (sneakily) install version 3, and not 2.1 as it did a couple of weeks ago.
  • After lots of trial and error, it seems that the above tutorial will not work with NLog 3, and my assumption is that some changes broke something.

Does anybody know if/what those changes might be, and whether or not other surprises features should be expected?


After some digging and reading, might this have anything to do with the fact that in NLog 3 they dropped support for .Net2 , and that Growl target is .Net 2 ?


Solution

  • I examined the code of NLogGrowlNotify and ran the target with several versions of NLog. It appears that even NLog 2.1.0 fails with this target. The problem lays in the fact that in the default configuration of the NLogGrowlNotify target the port is not set. The code of the target defaults to port 23053.

    So, to get the NLogGrowlNotify target to work with version 2.1.0 and version 3.0 of NLog just specify the port in your target config. Like so:

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

    It works fine with the demo app in the NLogGrowlNotify solution.

    update: NLog 3.0 depends on (at least) .Net v3.5. So in order to confirm the above, make sure you are targeting that framework.