0

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?

Community
  • 1
  • 1
Youngjae
  • 24,352
  • 18
  • 113
  • 198
  • Is this also the case with NLog 4.3? There are some changes regarding the _providerName_ in NLog 4.3 – Julian Apr 16 '16 at 12:58
  • @Julian // yes. I did it with latest version. I changed/omitted `providerName` but nothing happened well. – Youngjae Apr 16 '16 at 13:38
  • I think NLog this will only work if NLog does know how to read csdef files. I think we can add that easily if we know how to do that in C#. If you like, create a feature request: https://github.com/NLog/NLog/issues/new – Julian Apr 20 '16 at 21:37
  • This could be also helpful: https://maximelabelle.wordpress.com/2015/01/16/integrating-nlog-with-azure-cloud-service-diagnostics/ – Julian Apr 20 '16 at 21:37

0 Answers0