title: How do I store my Logs to Azure Table Store from Asp Net Core WebApi?
body: <p>I have ASP .Net Core WebApi application that is using .Net Framework 4.6. I am using NLog for logging. I want to log to Azure Table Storage. For that I am using 
  AzureTableStorageNLogTarget and NLogExtensions.Logging Nuget Packages.</p>
  
  <p>Latest Stable Release for AzureTableStorageNLogTarget is 1.0.9 but when I use that I am getting following Exception:</p>
  
  <pre><code>Could not load type 'Microsoft.Azure.CloudConfigurationManager' from assembly 
  </code></pre>
  
  <p>So I am using version 1.0.8.</p>
  
  <p>Now I am getting following exception:</p>
  
  <pre><code>Error Error initializing target 'AzureTableStorage Target[AzureTableStorageTarget]'. Exception: System.ArgumentNullException: Value cannot be null.
  Parameter name: connectionString
  </code></pre>
  
  <p>Googling the error gives me that It is not able to find Azure Table Storage ConnectionString, I don't understand why.</p>
  
  <p>Here is my NLog.Config </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        autoReload="true"
        internalLogLevel="Warn"
        internalLogFile="c:\temp\internal-nlog.txt"&gt;
    &lt;extensions&gt;
      &lt;add assembly="NLog.Extensions.AzureTableStorage"/&gt;
    &lt;/extensions&gt;
    &lt;!-- define various log targets --&gt;
    &lt;targets&gt;
      &lt;!-- write logs to file --&gt;
      &lt;target xsi:type="File" name="allfile" fileName="c:\temp\WebAPI-nlog-all-${shortdate}.log"
                  layout="${longdate}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}|${message} ${exception}" /&gt;
  
  
      &lt;target xsi:type="File" name="ownFile-web" fileName="c:\temp\WebAPI-nlog-own-${shortdate}.log"
               layout="${longdate}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}|  ${message} ${exception}" /&gt;
  
  
      &lt;target xsi:type="AzureTableStorage"
              name="AzureTableStorageTarget"
              ConnectionStringKey="AzureStorageConnectionString"
              TableName="LogTable" /&gt;
      &lt;target xsi:type="Null" name="blackhole" /&gt;
    &lt;/targets&gt;
  
    &lt;rules&gt;
      &lt;!--All logs, including from Microsoft--&gt;
      &lt;logger name="*" minlevel="Trace" writeTo="allfile" /&gt;
  
      &lt;!--Skip Microsoft logs and so log only own logs--&gt;
      &lt;logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" /&gt;
      &lt;logger name="*" minlevel="Trace" writeTo="ownFile-web" /&gt;
      &lt;logger name="*" minlevel="Trace" writeTo="AzureTableStorageTarget" /&gt;
    &lt;/rules&gt;
  &lt;/nlog&gt;
  </code></pre>
  
  <p>And my Appsetting.json: </p>
  
  <pre><code>{
    "Logging": {
      "IncludeScopes": false,
      "LogLevel": {
        "Default": "Debug",
        "System": "Information",
        "Microsoft": "Information"
      }
    },
    "AppSettings": {
      "AzureStorageConnectionString": "DefaultEndpointsProtocol=https;AccountName=sqdev01storage;AccountKey=&lt;key redacted&gt;"
    }
  
  }
  </code></pre>
  
  <p>A sample project is available on Git at: <a href="https://github.com/pankyog/NLogToAzureTable/tree/Re1" rel="nofollow noreferrer">https://github.com/pankyog/NLogToAzureTable/tree/Re1</a></p>