繁体   English   中英

如何让azure webrole记录所有404s

[英]how to get azure webrole to log all 404s

我一直在尝试使用azure为我的MVC项目工作,但到目前为止还没有取得多大成功。

我的ServiceConfiguration.Cloud.cscfg文件中有一个诊断连接字符串,它指向我的blob存储:

   ...
  <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.DiagnosticsConnectionString" value="**ConectionString**" />
</ConfigurationSettings>

我的web.config已设置跟踪

    ...
    <tracing>
      <traceFailedRequests>
        <remove path="*"/>
        <add path="*">
          <traceAreas>
            <add provider="ASP" verbosity="Verbose" />
            <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
            <add provider="ISAPI Extension" verbosity="Verbose" />
            <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module" verbosity="Verbose" />
          </traceAreas>
          <failureDefinitions timeTaken="00:00:15" statusCodes="400-599" />
        </add>
      </traceFailedRequests>
    </tracing>
  </system.webServer>

我的WebRole.cs有以下内容

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;

namespace MvcWebRole1
{
    public class WebRole : RoleEntryPoint
    {
        public override bool OnStart()
        {
         // Get the factory configuration so that it can be edited
         DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();


         // Set scheduled transfer interval for infrastructure logs to 1 minute
         config.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = System.TimeSpan.FromMinutes(1);

         // Specify a logging level to filter records to transfer

         config.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;

         // Set scheduled transfer interval for user's Windows Azure Logs to 1 minute
         config.Logs.ScheduledTransferPeriod = System.TimeSpan.FromMinutes(1);


         DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.DiagnosticsConnectionString", config);

         //RoleEnvironment.Changing += this.RoleEnvironmentChanging;

         return base.OnStart();
        }
    }
}

但我没有看到任何诊断日志

Azure Blob Stoage的屏幕截图

mam文件夹只包含一个MACommanda.xmlMASecretvsdeploy文件夹为空, wad-control-container必须为每个部署的文件。

我错过了什么/做错了吗?

我一直在尝试按照http://msdn.microsoft.com/en-us/library/windowsazure/gg433048.aspx中的指南进行操作,特别是http://channel9.msdn.com/learn/courses/Azure/Deployment/ DeployingApplicationsinWindowsAzure /运动-3监控-应用功能于Windows的天青

更新:

我发现以下可能是问题的一部分

IIS7日志未正确收集 - http://msdn.microsoft.com/en-us/library/hh134842

虽然这只应该说明404不能正常工作,但失败定义为15秒我的控制器操作中的17秒睡眠应该仍然记录

以下是我最终能够使用Azure Web角色进行所有日志记录的方法:

在WebRole.cs中包括以下内容:

 // Get the default initial configuration for DiagnosticMonitor.
        var config = DiagnosticMonitor.GetDefaultInitialConfiguration();

        // Filter the logs so that only error-level logs are transferred to persistent storage.
        config.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = config.Logs.ScheduledTransferLogLevelFilter = 
            config.WindowsEventLog.ScheduledTransferLogLevelFilter = LogLevel.Verbose;

        // Schedule a transfer period of 30 minutes.
        config.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = config.Logs.ScheduledTransferPeriod = config.WindowsEventLog.ScheduledTransferPeriod = 
            config.Directories.ScheduledTransferPeriod = config.PerformanceCounters.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);

        // Specify a buffer quota.
        config.DiagnosticInfrastructureLogs.BufferQuotaInMB = config.Logs.BufferQuotaInMB = config.WindowsEventLog.BufferQuotaInMB = 
            config.Directories.BufferQuotaInMB = config.PerformanceCounters.BufferQuotaInMB = 512;

        // Set an overall quota of 8GB maximum size.
        config.OverallQuotaInMB = 8192;

        // WindowsEventLog data buffer being added to the configuration, which is defined to collect event data from the System and Application channel
        config.WindowsEventLog.DataSources.Add("System!*");
        config.WindowsEventLog.DataSources.Add("Application!*");

        // Use 30 seconds for the perf counter sample rate.
        TimeSpan perfSampleRate = TimeSpan.FromSeconds(30D);

        config.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration()
        {
            CounterSpecifier = @"\Memory\Available Bytes",
            SampleRate = perfSampleRate
        });

        config.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration()
        {
            CounterSpecifier = @"\Processor(_Total)\% Processor Time",
            SampleRate = perfSampleRate
        });

        config.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration()
        {
            CounterSpecifier = @"\ASP.NET\Applications Running",
            SampleRate = perfSampleRate
        });



        // Start the DiagnosticMonitor using the diagnosticConfig and our connection string.
        DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString",config);


        return base.OnStart();

在system.WebServer下的web.config中添加以下内容:

    <tracing>
  <traceFailedRequests>
    <remove path="*"/>
    <add path="*">
      <traceAreas>
        <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
        <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module" verbosity="Verbose" />
      </traceAreas>
      <failureDefinitions statusCodes="400-599" />
    </add>
  </traceFailedRequests>
</tracing>

在服务定义文件中,在Web角色下添加以下内容:

 <LocalResources>
  <LocalStorage name="DiagnosticStore" sizeInMB="8192" cleanOnRoleRecycle="false"/>
</LocalResources>

这应该允许您在MVC应用程序中的所有日志记录。

您可以尝试从“failureDefinitions”节点中删除“timeTaken”属性吗? 参考: http//msdn.microsoft.com/en-us/library/aa965046( v = VS.90).aspx

通过查看wad-control-container中的相应文件来检查部署的诊断设置。

我注意到您没有根据我的经验设置DiagnosticInfrastructureLogs或Logs的所有必需值,包括bufferQuotaInMB和scheduledTransferLogLevelFilter。

尝试这个:

             // Get the factory configuration so that it can be edited
         DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();

         config.DiagnosticInfrastructureLogs.bufferQuotaInMB = 512;
         config.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = System.TimeSpan.FromMinutes(1D);
         config.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;

         config.Logs.bufferQuotaInMB = 512;
         config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
         config.Logs.ScheduledTransferPeriod = System.TimeSpan.FromMinutes(1D);

试着开始吧。 确保您已添加跟踪侦听器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM