最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Azure App Service Log File Fails To Update after First Write - Stack Overflow

programmeradmin3浏览0评论

I'm having some trouble with logging in Azure. I'm using the AzureAppServices FileLoggingProvider.

It doesn't seem to be a simple configuration issue as I can actually confirm that for the first log message that get's written (the first time a new log file is created) the logging is working correctly and I can see it within the log stream in the azure portal. After that no log messages are written. I thought it might be a buffering issue but I waited for 20 minutes and still didn't see any new log messages coming in. If I delete the log file then new log messages are immediately written to a new file and I can see them in the log stream. I'm using mostly default options for my logging configuration

builder.Services.Configure<AzureFileLoggerOptions>(options =>
{
    options.FileName = "azure-diagnostics-";
    options.FileSizeLimit = 50 * 1024;
    options.RetainedFileCountLimit = 5;
});

I'm having some trouble with logging in Azure. I'm using the AzureAppServices FileLoggingProvider.

It doesn't seem to be a simple configuration issue as I can actually confirm that for the first log message that get's written (the first time a new log file is created) the logging is working correctly and I can see it within the log stream in the azure portal. After that no log messages are written. I thought it might be a buffering issue but I waited for 20 minutes and still didn't see any new log messages coming in. If I delete the log file then new log messages are immediately written to a new file and I can see them in the log stream. I'm using mostly default options for my logging configuration

builder.Services.Configure<AzureFileLoggerOptions>(options =>
{
    options.FileName = "azure-diagnostics-";
    options.FileSizeLimit = 50 * 1024;
    options.RetainedFileCountLimit = 5;
});
Share Improve this question edited 2 days ago Suresh Chikkam 3,3802 gold badges4 silver badges12 bronze badges Recognized by Microsoft Azure Collective asked Feb 17 at 15:52 Luke BrooksLuke Brooks 1 New contributor Luke Brooks is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 2
  • The issue above occurs when file locking or log buffering happens within the logging provider. have tries alternate with enabling application insights. – Suresh Chikkam Commented Feb 18 at 6:23
  • Try reducing FileSizeLimit. – Suresh Chikkam Commented Feb 18 at 7:14
Add a comment  | 

1 Answer 1

Reset to default 0

Many of the users have reported that the log file becomes locked, preventing further writes. Deleting the existing log file forces the system to create a new one, this will temporarily resolve the issue.

And also, observed that logs are buffered and not immediately flushed to the file system, leading to delays in log visibility. Adjusting the logging configuration to reduce buffering intervals can clear this problem.

  • Try using Application Insights, it is a telemetry and logging platform offers real-time monitoring of log events. Add the Microsoft.Extensions.Logging.ApplicationInsights package and configure Application Insights in the app.
builder.Services.AddApplicationInsightsTelemetry();
builder.Logging.AddApplicationInsights();

Monitor logs in the Azure Portal under the Application Insights resource.

发布评论

评论列表(0)

  1. 暂无评论