3

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

user230910
  • 2,353
  • 2
  • 28
  • 50

2 Answers2

3

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.

Matt Tester
  • 4,663
  • 4
  • 29
  • 32
1

So logging to blob storage, think of it as uploading existing files to the blob storage. If your current app creates files, then you should use put blob property or blob append to add these files to blob storage. So you must interact with the storage SDK to make these transactions. You could also leverage logic apps which uses connectors to blob storage, and would perform certain actions based on specific triggers(time stamp and other conditions).

If you would like to see the generated logs in Azure Storage, you'll have to enable azure diagnostics but these logs would pertain to the storage account itself, not your app.

Since you mentioned that you see the output, you have to transfer that output as an object ex: (text file), then upload it to the storage account. You can find SDK information for C# here. I hope this helps.