public void WriteToLogWithLevel( string property, string description, LogLevel level) { switch (level) { case LogLevel.Information: ObserverLogger.LogInfo("{0} logged at level {1}: {2}", property, level, description); break; case LogLevel.Warning: ObserverLogger.LogWarning("{0} logged at level {1}: {2}", property, level, description); break; case LogLevel.Error: ObserverLogger.LogError("{0} logged at level {1}: {2}", property, level, description); break; default: throw new ArgumentOutOfRangeException(nameof(level), level, null); } Logger.Flush(); }
private Task CheckWuAutoDownloadEnabledAsync(CancellationToken token) { token.ThrowIfCancellationRequested(); // Windows Update Automatic Download enabled (automatically downloading an update without notification beforehand)? // If so, it's best to disable this and deploy either POA (for Bronze durability clusters) // or enable VMSS automatic OS image upgrades for Silver+ durability clusters. // This is important to prevent unexpected, concurrent VM reboots due to Windows Updates. try { var wuLibAutoUpdates = new AutomaticUpdatesClass(); this.isWindowsUpdateAutoDownloadEnabled = wuLibAutoUpdates.ServiceEnabled && wuLibAutoUpdates.Settings.NotificationLevel == AutomaticUpdatesNotificationLevel.aunlScheduledInstallation; } catch (Exception e) when( e is COMException || e is InvalidOperationException || e is SecurityException || e is Win32Exception) { ObserverLogger.LogWarning( $"{AuStateUnknownMessage}{Environment.NewLine}{e}"); this.auStateUnknown = true; } return(Task.CompletedTask); }
public void WriteToLogWithLevel(string property, string description, LogLevel level) { switch (level) { case LogLevel.Information: ObserverLogger.LogInfo("{0} logged at level {1}: {2}", property, level, description); break; case LogLevel.Warning: ObserverLogger.LogWarning("{0} logged at level {1}: {2}", property, level, description); break; case LogLevel.Error: ObserverLogger.LogError("{0} logged at level {1}: {2}", property, level, description); break; } Logger.Flush(); }