Question

I'm developing an app. using Common.Logging (http://netcommon.sourceforge.net/index.html). A simplified logging configuration (which is done in web.config) is as follows:

<configuration>
   ...
   <arg key="configType" value="FILE" />
   <arg key="configFile" value="NLog.config" />
   ...
</configuration> 

As you can see here, the configuration points another configuration file (here, NLog.config) of a backend logging framework.

My question is: when deploying in Azure, what path should I specify here (on dev, NLog.config is copied when building the solution, and placed in the bin directory). In other words, what would be the SAFEST way to get the physical place where the app is deployed in Azure?

Thanks in advance!

Was it helpful?

Solution

In code you can find the current path to the application using Server.MapPath("/"). Now, you can simply make sure that the NLog.config file gets deployed to the application folder:

  1. Add NLog.config to your project (in the root of your web application)
  2. Change the Build Action to Content

In order to test this you can right click on your Azure project an choose Package. In the bin\Release|Debug\app.publish folder of your Azure project you'll find a *.cspkg file. Add a .zip extension to this file and open the file with WinRAR/ZIP/7zip/... Then you'll see a file like this one: SomeWebRole_1a91f39a-49b7-4ece-873f-862172a2fa06.cssx. Here again, add the .zip extension to this file and open it.

If you navigate to the sitesroot\0 folder you'll see the files of the web application in IIS, including the NLog.config file. This way, you' can simply reference the NLog.config file in the Common.Logging settings:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top