saleem-mirza / serilog-sinks-azure-analytics

Serilog sink which writes to Azure analytics
Apache License 2.0
62 stars 45 forks source link

Reading parameters from Azure App Service' settings doesn't work #67

Closed Pepo-BG closed 2 years ago

Pepo-BG commented 2 years ago

Describe the bug Hello, I have a .NET 6 Minimal API. For local development, all my settings are in appsettings.json. When I set the Azure Analytics parameters there - everything works as expected - my logs are logged and can be found in the Azure Analytics. But for UAT and Prod, I keep my configurations in App Service's settings. So I tried to set Serilog parameters ther but seems that they can't be read and there aren't any records logged in Azure Analytics.

To Reproduce Steps to reproduce the behavior: In Azure App Service add settings like:

Also, I tried with the following format:

But still the same

Expected behavior All my logs are stored in Azure Analytics.

Screenshots image

Additional context Here is a working code example, when I put my settings in appsettings.json - file and still read the serilog:using:AzureLogAnalytics = Serilog.Sinks.AzureAnalytics from Azure App Service's settings:

"Serilog": {
        "WriteTo": [
            {
                "Name": "AzureAnalytics",
                "Args": {
                    "logName": "My_app",
                    "authenticationId": "{my_Authid_here}",
                    "workspaceId": "{my_workspaceId_here}"
                }
            }
        ],
        "MinimumLevel": {
            "Default": "Information",
            "Override": {
                "Microsoft.AspNetCore": "Warning",
                "Grpc": "Debug"
            }
        }
    }
Pepo-BG commented 2 years ago

Seems the changes weren't implemented before restarting the App Service. After restart - it works as expected.