2011-08-05 8 views
0

私は小さなボタンをクリックすると、さまざまな種類のロギングデータが収集されます。しかし、私がコードを実行すると、通常、ログに記録されたデータはサーバーエクスプローラでチェックされ、ログに記録されても反映されず、長期間(15〜20分)表示されます。このコードを書いている間に私がコミットしたミスはありますか?コードの一部は以下の通りです::診断データがログに記録されるのに時間がかかりますazure

DiagnosticMonitorConfiguration diagMonitorConfiguration; 
    RoleInstanceDiagnosticManager roleInstanceDiagnosticManager; 
    protected void Page_Load(object sender, EventArgs e) 
    { 


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

     // Configures the transfer period for basic windows azure logs 
     diagMonitorConfiguration.Logs.ScheduledTransferPeriod = TimeSpan.FromSeconds(10); 

     // Configures the log type to be Verbose 
     diagMonitorConfiguration.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose; 

     // Start the diagnostics monitor 
     //DiagnosticMonitor.Start(CloudStorageAccount.DevelopmentStorageAccount, diagConfig); 

     //CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString")); 

     CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount; 
     roleInstanceDiagnosticManager = storageAccount.CreateRoleInstanceDiagnosticManager(RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance.Role.Name, RoleEnvironment.CurrentRoleInstance.Id); 

     //DiagnosticMonitorTraceListener tmpListener = new DiagnosticMonitorTraceListener(); 
     //System.Diagnostics.Trace.Listeners.Add(tmpListener); 
    } 

    // Used to trace custom warning messages 
    protected void btnWarning_Click(object sender, EventArgs e) 
    { 
     // tracing user message as a warning 
     System.Diagnostics.Trace.TraceWarning("WARNING ENCOUNTERED :" + TextBoxName.Text); 
    } 

    // tracing custom error messages 
    protected void btnError_Click(object sender, EventArgs e) 
    { 
     // To log the user message as an error 
     .......TraceError("ERROR ENCOUNTERED :" + TextBoxName.Text); 
    } 

    // tracing custom information messages 
    protected void btnInformation_Click(object sender, EventArgs e) 
    { 
     // To log the user message as mere information 
     .........TraceInformation("INFORMATION SENT :" + TextBoxName.Text); 
    } 

    // used to enable diagnostic infrastructure logs to be collected 
    protected void btnEnableInfrastructure_Click(object sender, EventArgs e) 
    { 
     // configuring the type and transfer period for the Infrastructure logs 
     diagMonitorConfiguration.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = some filter; 
     diagMonitorConfiguration.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = SOME TIME PERIOD    
     // Update the configuration setting for the diagnostic manager 
     roleInstanceDiagnosticManager.SetCurrentConfiguration(diagConfig); 
     Thread.Sleep(5000); 

    } 

    // used to enable crash dumps for the application 
    protected void btnEnableCrashDumps_Click(object sender, EventArgs e) 
    { 
     //enabling crash dumps 
     CrashDumps.EnableCollection(true); 

     // Update the configuration setting for the diagnostic manager 
     roleInstanceDiagnosticManager.SetCurrentConfiguration(diagConfig); 
     Thread.Sleep(5000); 
    } 

    // used to enable the collection windows event logs 
    protected void btnEnableEventLogs_Click(object sender, EventArgs e) 
    { 
     //Configuring the Windows Event logs 
     diagMonitorConfiguration.WindowsEventLog.ScheduledTransferLogLevelFilter = LogLevel.Verbose; 

     // two types of events, application and system data are logged 
     diagMonitorConfiguration.WindowsEventLog.DataSources.Add("some source"); 

     // the time interval is configured as 5 seconds 
     diagMonitorConfiguration.WindowsEventLog.ScheduledTransferPeriod = some time period; 

     // Update the configuration setting for the diagnostic manager 
     roleInstanceDiagnosticManager.SetCurrentConfiguration(diagConfig); 
     Thread.Sleep(5000); 
    } 

    protected void btnEnablePerfCounters_Click(object sender, EventArgs e) 
    { 

     // configuring the performance counter data to be collected. processor time is collected 
     diagMonitorConfiguration.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration() 
     { 
      THE REQD PARAMETERS 
     }); 

     // similarly available memory data is also logged 
     diagMonitorConfiguration.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration() 
     { 
      THE REQD PARAMETERS 
     }); 

     // the scheduled time transfer is configured to 5seconds 
     diagMonitorConfiguration.PerformanceCounters.ScheduledTransferPeriod = some time period; 

     //DiagnosticMonitor.Start(CloudStorageAccount.DevelopmentStorageAccount, diagConfig); USED PREVIOUSLY 

     // Update the configuration setting for the diagnostic manager 
     roleInstanceDiagnosticManager.SetCurrentConfiguration(diagConfig); 
     Thread.Sleep(5000); 
    } 
} 

答えて

2

IIRC、1分が最小転送時間のようです。あなたが何か小さいものに設定すると、何が起こるか完全にわからない。結果の制御ファイル(wad-controlコンテナ内)を確認し、実際に転送速度がどのように設定されているかを確認することができます。これは非同期処理(ログ、ローカルバッファ、転送)に留意してください。リアルタイムに何かをしたいのであれば、tracelistenerをテーブルやブロブに直接記録するように適応させる必要があります(またはService Busのトレースを使用する)。これを行う方法についてはCheck the training kit on debuggingをご覧ください。 docs 1として

1

ScheduledTransferPeriodプロパティが データバッファが永続ストレージにローカルログデータを転送する頻度を設定するために使用されます。 デフォルトでは、このプロパティは、 の意図しないストレージコストを防ぐためのデータバッファには設定されていません。

このプロパティに設定する値は、最も近い 分に切り上げられます。したがって、指定できる最小転送時間は、1 分です。

0

確かに言うことはできませんが、SetCurrentConfiguration()への複数の呼び出しがあります。前回私がチェックしたときには、これは一度だけ呼び出すことができました。私はそれを複数回呼び出すことによってどのような振る舞いが観察されるのか全く分かりません。私は実際にはすべての診断設定コードを1つの場所に集約することをお勧めします。おそらくglobal.asaxにあり、いくつかのボタンハンドラには散らばりません。

関連する問題