Search code examples
azureloggingazure-blob-storagetraceazure-cloud-services

Azure Cloud Service (Classic) - Any way to log Diagnostic.Trace logs to BLOB storage


I've been asked to change an old Azure Cloud Service worker's logging to the System.Diagnostics.Trace logging style of logging. I've done that and now I'm about ready to deploy it to azure.

The client requirement is that these logs should appear in blob storage, similar to how the more modern app service logs can be configured to write their diagnostics to blob storage. There is an expectation that logs can be batched up and uploaded periodically (perhaps time or number of lines based).

Is there a nuget package or other library or config I should enable to connect the application to blob storage? I've spent about 20 mins searching here and online for a solution, but information seems to mainly talk about writing logs to Table Storage..

Edit: More detail:

  • This is an existing app (C# .Net Framework 4.5) that used to use an external logging service.
  • I assumed (incorrectly, I think) that the logging to blob storage was something I could configure in the Azure Portal.
  • As things are right now, NO log file of any kind is generated, but when I run the code in Visual Studio, I can see some Output from the logging statements
  • I have updated the code to use a standard (custom) logging system that eventually boils down to using statements like the below:

Trace.TraceInformation($"DEBUG: {message}");

Here are some links I found with related information:

Streaming from command line

Trace listener question

Adding Trace to existing website

Performance Impact of Logging

Smarx Library


Solution

  • The logging is configured by the diagnostics.wadcfgx file which you can see in your solution.

    enter image description here

    This holds all of the diagnostic information that you want to collect. This can be controlled via the "Properties" of the Web\Worker role (right-click -> Properties).

    From there, there is also the option to specify the Storage Account: enter image description here

    This isn't always ideal if you are deploying to multiple environments, so you should be able to alter the configuration from the Azure Portal, by downloading and uploading new configuration, following these instructions.