title: How can I stop NLog from double logging
body: <p>I'm writing a WEB API call for NLog, so remote apps can log to my logging table.  </p>
  
  <p>In my controller I have (hard-coded for now as a sanity check):</p>
  
  <pre><code>NLogger.LogError("Some Error Message", "An exception", 5, "A computer name"); 
  </code></pre>
  
  <p>Then my static LogError method looks like this (I tried LogEventInfo() too):</p>
  
  <pre><code>public static void LogError(string msg, string ex, int appid, string machineName)
  {
      LogEventInfo logEvent = new LogEventInfo(LogLevel.Error, "Api Logger", "Another test msg");
      logEvent.Properties["myMsg"] = msg;
      logEvent.Properties["myEx"] = ex;
      logEvent.Properties["myAppId"] = appid;
      logEvent.Properties["myMachineName"] = machineName;
      NLogManager.Instance.Log(logEvent);
  }
  </code></pre>
  
  <p>Lastly, this is my code first config for that rule (there's 2 others with different db targets):</p>
  
  <pre><code>private static void ConfigureApiLog()
  {
      var dbApiErrorTarget = new DatabaseTarget
      {
          ConnectionString = ConnectionFactory.GetSqlConnection().ConnectionString,
          CommandText = "usp_LogError",
          CommandType = CommandType.StoredProcedure
      };
  
      dbApiErrorTarget.Parameters.Add(new DatabaseParameterInfo("@level",
          new global::NLog.Layouts.SimpleLayout("${level}")));
      dbApiErrorTarget.Parameters.Add(new DatabaseParameterInfo("@logger",
          new global::NLog.Layouts.SimpleLayout("${logger}")));
      dbApiErrorTarget.Parameters.Add(new DatabaseParameterInfo("@message",
          new global::NLog.Layouts.SimpleLayout("${event-properties:item=myMsg}")));
      dbApiErrorTarget.Parameters.Add(new DatabaseParameterInfo("@exception",
          new global::NLog.Layouts.SimpleLayout("${event-properties:item=myEx}")));
      dbApiErrorTarget.Parameters.Add(new DatabaseParameterInfo("@AppId",
          new global::NLog.Layouts.SimpleLayout("${event-properties:item=myAppId}")));
      dbApiErrorTarget.Parameters.Add(new DatabaseParameterInfo("@MachineName",
          new global::NLog.Layouts.SimpleLayout("${event-properties:item=myMachineName}")));
  
      Config.AddTarget("database", dbApiErrorTarget);
  
      Config.LoggingRules.Add(new LoggingRule("*", LogLevel.Error, LogLevel.Fatal, dbApiErrorTarget));
  }
  </code></pre>
  
  <p>I expect 1 log per log call to the logger instance, but I'm getting two and I'm not exactly sure why:</p>
  
  <pre><code>   Id   Date    Level   Logger  Message Exception   AppId   MachineName
  1   2017-03-03 22:43:20.557 Error   Api Logger  Another test msg        0   mylocalmachine
  2   2017-03-03 22:43:20.603 Error   Api Logger  Some Error Message  An exception    5   A computer name
  </code></pre>
  
  <p>AppId 0 is my Api, 5 is some remote app, hard coded at this point as POC.</p>
  
  <p>Might be that it's Friday, but I can't seem to figure out what's wrong with the code.  Any help would be appreciated!</p>