2012-09-05 52 views
3

我一直在試圖讓記錄與湛藍我的MVC項目,但到目前爲止,還沒有多少成功的工作。如何讓蔚藍webrole記錄所有404

我在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(); 
     } 
    } 
} 

但我沒有看到任何診斷日誌

Screenshot of 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/Exercise-3-Monitoring-Applications-in-Windows-Azure

更新遵循指南:

我發現這可能是問題

IIS7日誌不會一部分的以下妥善收集 - http://msdn.microsoft.com/en-us/library/hh134842

雖然這應該只佔404不工作,與15秒的失敗定義我的17秒睡眠我的控制器行動應該仍然被記錄

回答

0

你可以嘗試通過刪除「timeTaken」屬性從「 failureDefinitions「節點? Ref:http://msdn.microsoft.com/en-us/library/aa965046(v=VS.90).aspx

+0

立即嘗試,等待它部署。在我的控制器操作中,我有一個睡眠(17000),應該根據channel9指南觸發timeTaken日誌記錄,但根本沒有看到全部創建的文件夾 – Tom

0

檢查部署的診斷,以通過在WAD控制容器查看相應的文件設置。

我注意到你沒有設置我的經驗是診斷基礎設施日誌或日誌的所有必需值,包括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); 

嘗試,要開始。確保您已添加跟蹤偵聽器。

2

這裏是我終於能夠把所有的日誌記錄在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(); 

在web.config下系統。Web服務器添加以下內容:

<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應用程序中所有的記錄。