NLog connectionStringName for Azure Worker Role csdef

时间:2016-04-15 15:01:00

标签: app-config nlog azure-worker-roles

I'm trying to use NLog with Azure SQL as log DB in order to trace processes in Azure Worker Role.

It works when I set connectionString in NLog.config as below.

<target name="database"
    connectionString=Server=tcp:some.database.windows.net,1433...`
    ...
/>

But I'd like to use connectionStringName given from ServiceConfiguration.csdef which overridden result of App.Config.

App.Config defines connection string as below,

<appSettings>
    <add key="LogConnectionString" value="Server=tcp:some.database.windows.net,1433;..." />
</appSettings>

And, ServiceConfiguration.csdef defines its value to Dev/Test/Live separately.

The NLog throws exception during initialization as below.

---> NLog.NLogConfigurationException: Connection string 'LogConnectionString' is not declared in section.

Note that, Adding providerName in App.Config did not help. It seems that providerName property does not propagate to csdef configuration.

Can I achieve this without SlowCheetah config transform?

0 个答案:

没有答案