- 
                Notifications
    
You must be signed in to change notification settings  - Fork 20
 
Open
Description
Recently I've been converting out sql server logging using nlog to azure data tables, using your AzureStorage extension. Everything works great when I set the connection string via text in the nlog config file, or via the appsettings. However due to security restrictions I must load the connection string from a keyvault on startup. I have modified my nlog.config like so:
<?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" internalLogLevel="Trace" internalLogToConsole="true">
  <extensions>
    <add assembly="NLog.Extensions.AzureDataTables" /> 
  </extensions>
  <targets>
    <target xsi:type="AzureDataTables"
            connectionString="${var:storageConnectionString}"
            name="AzureTable"
            tableName="ErrorLogs">
      <contextproperty name="CallSite" layout="${callsite:filename=true}" />
      <contextproperty name="Date" layout="${longdate}" />
      <contextproperty name="Exception" layout="${exception}" />
      <contextproperty name="Level" layout="${level}" />
      <contextproperty name="Logger" layout="${logger}" />
      <contextproperty name="MachineName" layout="${machinename}" />
      <contextproperty name="Message" layout="${message}" />
      <contextproperty name="StackTrace" layout="${stacktrace}" />
      <contextproperty name="Thread" layout="${threadid}" />
    </target>
  </targets>
  <rules>
    <logger name="*" writeTo="AzureTable"  />
  </rules>
</nlog>
and set that during my Startup.cs using the following:
LogManager.Configuration.Variables["storageConnectionString"] = Settings.StorageConnectionString;
The connection string never gets set using that method. Is there a workaround for this?
Metadata
Metadata
Assignees
Labels
No labels