How to modify Blob storage path for Azure Web App Diagnostics logs

722 views Asked by At

I have a .Net Core 2.0 Web service which is deployed on Microsoft Azure. In my application I am using Azure Web App Diagnostics to store logs in the Blob storage.

The logs files are split according to hours. Currently the blob file path would be something like {year}/{month}/{date}/{hour}/{filename}. Having a new folder for every hour.

I want to change this storage path and store daily logs in one file. I am using LoggerFactory for logging. I have added the AzureWebAppDiagnostics in the Configure method in Startup.cs

loggerFactory.AddAzureWebAppDiagnostics(
            new AzureAppServicesDiagnosticsSettings
            {
                OutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss zzz} [{Level}] {RequestId}-{SourceContext}: {Message}{NewLine}{Exception}"
            }
            );

I understand that there are other ways of logging such as using NLog or SeriLog but is there any out of the box way of doing what I mentioned above?

1

There are 1 answers

0
Fei Han On

Currently the blob file path would be something like {year}/{month}/{date}/{hour}/{filename}. Having a new folder for every hour. I want to change this storage path and store daily logs in one file.

I checked the class AzureAppServicesDiagnosticsSettings and find that it just enables us to specify the last section of log blob name, it does not enable us to specify the full name of blob.

//
// Summary:
//     Gets or sets the last section of log blob name. Defaults to "applicationLog.txt".
public string BlobName { get; set; }

You can open an issue and track the status. Besides, as you mentioned, you can integrate NLog etc to write log to Azure Storage.