dotnet / dotnet/aspnetcore

Microsoft.Extensions.Logging.AzureAppServices not sending logs to Blob Storage

Open
#28,486 8 comments 5 reactions 0 assignees View on GitHub
area-networking feature-azure
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

I am trying to save application logs in Azure Blob Storage using Microsoft.Extensions.Logging.AzureAppServices with ILogger interface. The code to configure the provider in Program.cs is this:
```
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.AddAzureWebAppDiagnostics();
})
.ConfigureServices(serviceCollection =>
{
serviceCollection
.Configure(options =>
{
options.BlobName = "test.txt";
});
})
.ConfigureAppConfiguration((context, builder) =>
{
if (context.HostingEnvironment.IsDevelopment())
builder.AddUserSecrets();
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup();
});
```

and, the code that logs:
```
[HttpGet]
public async Task GetActiveTabloids()
{
_logger.LogTrace("{0} - Executando consulta de tabloides", DateTime.Now);
_logger.LogDebug("{0} - Executando consulta de tabloides", DateTime.Now);
_logger.LogInformation("{0} - Executando consulta de tabloides", DateTime.Now);
_logger.LogError("{0} - Executando consulta de tabloides", DateTime.Now);
_logger.LogCritical("{0} - Executando consulta de tabloides", DateTime.Now);

var availableTabloids = await _getActiveTabloidsQuery.Execute();

return Ok(new
{
tabloids = availableTabloids
});
}
```

I'm using .net core 3.1 with Microsoft.Extensions.Logging.AzureAppServices 5.0.0. After few attempts, I downgraded the package to 3.1.10, and 3.1.4, but nothing works.

The app service logs is configured on Azure to log just in blob. When set to logging in Filesystem, the logs are streamed correctly.
![image](https://user-images.githubusercontent.com/11728772/101408297-fb880500-38ba-11eb-969f-c77419412cce.png)

The problem is that the logs is not send to the configured Blob storage.

This is the container after a request made to the endpoint show above:
![image](https://user-images.githubusercontent.com/11728772/101409435-ac42d400-38bc-11eb-8341-b930d5cd4a99.png)

I noted that the ASP.NET Core Logging Integration installed in the app service is 5.0.0, but not found a way to downgrade this extension.

![image](https://user-images.githubusercontent.com/11728772/101408985-efe90e00-38bb-11eb-84ce-c41adb98c5fa.png)

Can anyone help on how to fix this?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.