0

さまざまなボタンをクリックすると、さまざまな種類のログデータが収集される小さなコードを作成しました。ただし、コードを実行すると、通常、ログに記録されたデータはサーバー エクスプローラーで確認しても反映されず、ログに記録されていても、長時間 (15 ~ 20 分) 後に表示できます。このコードの作成中に犯した間違いはありますか。コードの一部を以下に示します::

    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);
    }
}
4

3 に答える 3

2

IIRC、1分が最小転送時間のようです。小さい値に設定するとどうなるかは完全にはわかりません。結果の制御ファイル (wad-control コンテナー内) をチェックして、転送速度が実際にどのように設定されているかを確認できます。これは非同期プロセスであることに注意してください (ログを記録し、ローカルにバッファリングしてから転送します)。リアルタイムで何かが必要な場合は、tracelistener を適応させて、テーブルまたは BLOB に直接ログを記録する (または Service Bus トレースを使用する) 必要があります。 これを行う方法については、デバッグに関するトレーニング キットを確認してください

于 2011-08-05T16:14:02.847 に答える
1

ドキュメントに従って:

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

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

于 2011-08-06T12:13:09.100 に答える
0

はっきりとは言えませんが、への呼び出しは複数ありますSetCurrentConfiguration()。前回チェックした時は一度しか電話できませんでした。何度も呼んで、どのような行動が見られるのかわかりません。すべての診断構成コードを1つの場所(おそらくglobal.asax内)に集約し、複数のボタンハンドラーに分散させないことをお勧めします。

于 2011-08-06T14:38:05.940 に答える