title: Cannot get NLog custom target to work
body: <p>I am really struggling to get a basic custom target working with NLog.</p>
  
  <p>Program.cs</p>
  
  <pre class="lang-cs prettyprint-override"><code>using NLog;
  using NLog.Targets;
  
  
  
  namespace NLogTestConsole
  {
      class Program
      {
          private static Logger logger = null;
  
          static Program()
          {
              logger = LogManager.GetCurrentClassLogger();
              Target.Register&lt;NLogTestConsole.Gerald&gt;("Gerald");
          }
  
          static void Main(string[] args)
          {
              logger.Trace("Sample trace message");
              logger.Debug("Sample debug message");
              logger.Info("Sample informational message");
              logger.Warn("Sample warning message");
              logger.Error("Sample error message");
              logger.Fatal("Sample fatal error message");
          }
      }
  }
  </code></pre>
  
  <p>NLogCustomTarget.cs</p>
  
  <pre class="lang-cs prettyprint-override"><code>using NLog;
  using NLog.Targets;
  
  
  
  namespace NLogTestConsole
  {
  
      [Target("Gerald")]
      public sealed class Gerald : TargetWithLayout
      {
          public Gerald()
          {
              // this.Host = "localhost";
          }
  
          //[RequiredParameter]
          //public string Host { get; set; }
  
          protected override void Write(LogEventInfo logEvent)
          {
              // Breakpoint here never gets hit
              string logMessage = this.Layout.Render(logEvent);
  
              System.Console.WriteLine("MYCUSTOMMSG:    " + logMessage);
          }
  
          private void SendTheMessageToRemoteHost(string host, string message)
          {
              // TODO - write me 
          }
      }
  
  }
  </code></pre>
  
  <p>NLog.config</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;nlog autoReload="true"
        throwExceptions="false"
        internalLogLevel="Off"
        internalLogFile="c:\temp\nlog-internal.log"&gt;
  
    &lt;!--  optional, add some variables
          https://github.com/nlog/NLog/wiki/Configuration-file#variables    --&gt;
    &lt;variable name="myvar" value="myvalue"/&gt;
  
    &lt;!--  See https://github.com/nlog/nlog/wiki/Configuration-file
          for information on customizing logging rules and outputs. --&gt;
    &lt;targets&gt;
      &lt;!--    add your targets here
              See https://github.com/nlog/NLog/wiki/Targets for possible targets.
              See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.    --&gt;
  
      &lt;!--    Write events to a file with the date in the filename.
              &lt;target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
                  layout="${longdate} ${uppercase:${level}} ${message}" /&gt;                    --&gt;
  
      &lt;target name="logfile" type="File" fileName="file.txt" /&gt;
      &lt;target name="console" type="Console" /&gt;
      &lt;target name="debugger" type="Debugger"/&gt;
      &lt;target name="Gerald" type="Gerald"/&gt;
    &lt;/targets&gt;
  
    &lt;rules&gt;
      &lt;!--  Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace)  to "f"
            &lt;logger name="*" minlevel="Debug" writeTo="f" /&gt;    --&gt;
  
      &lt;logger name="*" minlevel="Trace" writeTo="logfile" /&gt;
      &lt;logger name="*" minlevel="Info" writeTo="console" /&gt;
      &lt;logger name="*" minlevel="Trace" writeTo="debugger" /&gt;
      &lt;logger name="*" minlevel="Trace" writeTo="Gerald" /&gt;
    &lt;/rules&gt;
  &lt;/nlog&gt;
  </code></pre>
  
  <p>If I comment out the "Gerald" target I get logging to file, console, and debug output. With that line there, nothing works
  What have I got wrong?</p>
  
  <p>Thanks,</p>
  
  <p>Adam.</p>