Azure / azure-signalr

Azure SignalR Service SDK for .NET

Home Page:https://aka.ms/signalr-service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Azure SignalR ASP.NET (Full Framework) running on Azure App Service Pv3 results in excessive application logs

maskati opened this issue · comments

There is an issue when using a combination of the following:

  • Running a full framework ASP.NET application on a Windows App Service hosting plan
  • Running on App Service Plan of tier Premium v3
  • Configuring Azure App Service with an Azure Monitor diagnostic setting logging the App Service Application Logs (AppServiceAppLogs) category. This is required since ASP.NET Windows applications (running on IIS) have no console output.
  • Using Azure SignalR for ASP.NET library (Microsoft.Azure.SignalR.AspNet)
  • Resolving a version of the Microsoft.Extensions.Logging.EventSource library v6 or greater (issue does not manifest with v2 specified by Microsoft.Azure.SignalR.AspNet as the minimum dependency, have not investigated why the issue only manifests with newer EventSource library versions)

The issue results from:

  • Azure SignalR for ASP.NET startup creating a ILoggerFactory that configures an internal EventSource logger (AddEventSourceLogger)
  • The event source logger implementation emitting ETW events on the Windows for all SignalR events (also debug and trace events)
  • The App Service Premium v3 plan with AppServiceAppLogs category logging enabled consuming all platform ETW events and shipping them to Azure Monitor

The end result is a system that logs several million debug logs per day to Azure Monitor.

image

The way I see it the actual bug is a combination of bugs in both Azure SignalR for ASP.NET library and Azure App Service Windows hosting infrastructure:

  • Microsoft.Azure.SignalR.AspNet should not be creating its own internal logger factory with an event source logger over which the application has no control. Applications always create their own logging configuration and specify the desired targets. I understand the compatibility reason why it is done like this when integrating from full framework with Microsoft.Extensions.Logging, but it should be opt-in with some sort of flag, and the normal usage should result in the use of NullLogger.
  • App Service should not be emitting event source events to Azure Monitor from sources other than the officially declared AzureMonitorTraceListener (System.Diagnostics.Trace.Trace*). It should also be adhering to the APPSERVICEAPPLOGS_TRACE_LEVEL configuration (handled in Microsoft.WindowsAzure.WebSites.Diagnostics.AzureMonitorTraceListener) as well as the 100 logs/minute threshold implemented by the internal Microsoft.WindowsAzure.WebSites.Diagnostics.AzureMonitorTraceThrottler.

For now my workaround is to configure SignalR with a HubConfiguration and custom IDependencyResolver wrapping HubConfiguration.Resolver and for IDependencyResolver.GetService(Type serviceType) when serviceType = ILoggerFactory returning NullLoggerFactory.Instance.