Question

We use the Windows Azure Diagnostics Monitor Trace Listener to ship our trace logs to Azure Diagnostics. As we have a large number of verbose logs we have decided to stop shipping these to Azure Diagnostics to simply debugging.

However when we set the ScheduledTransferLogLevelFilter property it seems to be ignored by Azure Diagnostics; so all Verbose logs are still shipped.

The config section we use is:

<system.diagnostics>
    <trace>
        <listeners>
            <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                name="AzureDiagnostics">
                <filter type="" />
            </add>
        </listeners>
    </trace>
</system.diagnostics>

Whilst the code is:

var config = DiagnosticMonitor.GetDefaultInitialConfiguration();

config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Information;
config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1d);

DiagnosticMonitor.Start(CONNECTION_STRING, config);

Has anyone else come into this problem? Is there an additional section of set of configuration values that need to be set to stop Trace Logs shipping Verbose entries?

EDIT:

Avkash Chauhan got me on the right track; you need to explicitly save the configuration; the final code looks like this and functions as expected.

public static void StartLogging()
{
    var cloudStorageAccount = 
        CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(DEFAULT_CONNECTION_STRING));

    var roleInstanceDiagnosticManager =
        cloudStorageAccount.CreateRoleInstanceDiagnosticManager(
            RoleEnvironment.DeploymentId,
            RoleEnvironment.CurrentRoleInstance.Role.Name,
            RoleEnvironment.CurrentRoleInstance.Id);

    var config = roleInstanceDiagnosticManager.GetCurrentConfiguration();

    config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Information;
    config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1d);

    roleInstanceDiagnosticManager.SetCurrentConfiguration(config);

    // Start the diagnostic monitor with the modified configuration.
    DiagnosticMonitor.Start(DEFAULT_CONNECTION_STRING, config);
}
Était-ce utile?

La solution

I believe that you are not saving the configuration setting properly and this could cause the problem. In past I have seen that if you will not use SetCurrentConfiguration() with your config object the setting are not saved so when Diagnostics monitor run you will not see the effect. Try adding SetCurrentConfiguration() to check if that is the case.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top