0

We've 3 separate deployments:

  1. Azure App Service (Web API application) w/ no web-jobs
  2. Azure Dummy Web Site w/ 1 Web Job
  3. Azure Dummy Web site w/ 1 Web Job

We will update them from time-to-time; publishing to a Staging Deployment-Slot and then swapping the Staging slot to Production once we're comfortable w/ what was deployed. We sometimes do this for all 3 at the same time, and sometimes only 1 at a time.

The applications use NLog to to log interesting things (at DEBUG, INFO, etc.). We've configured xsi:type="File" targets that write to the local drive (which I realize is blob-backed and shared across all instances). We currently write to a location under %HOME%\site\wwwroot.

Problem with our approach is the log-files are bound to the particular Slot we happen to be running in.

So when we log in Production for a month, deploy to a Staging slot, then swap it to Production ... we wipe out the month's worth of NLog application logs. Actually it gets swapped over to Staging and we'd have to do some manually copying/moving to merge it with the new Production application log.

I am pretty sure we're missing something simple and we're doing this wrong, or the hard-way.

What is a way that we can "log" to one place assigned to "Production" and have that log data contain, in only one place, all the data logged by our application over multiple deployments to Production.

Howard Hoffman
  • 897
  • 1
  • 9
  • 22
  • I'm not 100% confident, but you can try to write your log to `%HOME%\site\` And you can also disable staging logging by using app settings. And those can be configured for each slot. – RAS Mar 14 '17 at 22:43
  • The file system (holding site content as well as log files) follows slot - so the file system log solution would not work if you want log always on PROD slot. Does NLog support custom logger? If so, you could write one to push to, say, common storage table. – Suwat Ch Mar 15 '17 at 00:35
  • This is true -- there are other NLog loggers out there. In addition to the TableStorage logger noted below by @Jambor-msft there is a Blob NLog logger. – Howard Hoffman Mar 15 '17 at 13:46

1 Answers1

1

As Suwat Ch said. If you swap your web app from production to staging, the log file will move to staging too. If you want to keep the logging file in production, I would suggest you save the log info at Azure storage. Please try AzureTableStorageNLogTarget to save log info at azure table storage. Here is a github resource which demonstrator how to use it. Hope this could give you tips.

Jambor - MSFT
  • 3,175
  • 1
  • 13
  • 16
  • I note there's also https://github.com/nickheppleston/NLog.AzureStorage. This question overlaps a bit with my use case: http://stackoverflow.com/questions/35058029/how-to-integrate-nlog-to-write-log-to-azure-streaming-log. I'm wondering also if https://learn.microsoft.com/en-us/azure/app-service-web/web-sites-enable-diagnostic-log will just-work, assuming we use an `xsi:type="Trace"` target in NLog config. The main thing I'm looking for is logs-that-contain-only-production-across-slot-swaps. – Howard Hoffman Mar 15 '17 at 13:51
  • As I know, there is no easy way to do this. all the files will be swapped to new slot. So if you want to keep it, you need to move to third party storage. You can also submit a customer voice at [Azure feedback forum](https://feedback.azure.com/forums/34192--general-feedback) – Jambor - MSFT Mar 17 '17 at 07:57
  • Assuming we configure Diagnostic Logs (as per the doc.microsoft.com link above) to write Application Log to Blob storage, and adjust our NLog configuration to target the .NET Trace it does strike me that we'll get the benefit of 3rd-party storage. Since NLog will write to Trace and our Trace will persist to Blob, and that this configuration is "per-slot" ... we will always have our "Production" logging to the Blob configured in the Diagnostic Logs blade of the slot. Does that make sense? – Howard Hoffman Mar 17 '17 at 22:10