private static void WriteToEventLog(Exception ex) { const string source = "Health.Direct.MdnMonitor"; EventLogHelper.WriteError(source, ex.Message); EventLogHelper.WriteError(source, ex.GetBaseException().ToString()); }
//--------------------------------------------------- // // Agent Initialization // //--------------------------------------------------- void Init(SmtpAgentSettings settings) { if (settings.FailedInit) { EventLogHelper.WriteError( new LogFileSettings().EventLogSource, "Failed Init! Using a disabled SmtpAgentSettings."); m_settings = settings; var log = new NLogFactory(settings.LogSettings); m_logger = log.GetLogger(GetType()); return; } m_settings = settings; m_settings.Validate(); m_auditor = IoC.ResolveAll <IAuditor <IBuildAuditLogMessage> >().ToList(); m_logger = Log.For(this); m_diagnostics = new AgentDiagnostics(this); m_configService = new ConfigService(m_settings); m_monitorService = new MonitorService(m_settings); using (new MethodTracer(Logger)) { try { // // First, setup defaults using Xml Config // this.InitDomains(); this.InitFolders(); this.InitRoutes(); this.InitNotifications(); // // Call config service, if any was configured // this.InitDomainsFromConfigService(); // // Finally, we can agent... // this.InitAgent(); this.SubscribeToAgentEvents(); this.ConfigureServicePoints(); } catch (Exception ex) { Logger.Error("While initializing {0}", ex.ToString()); throw; } } }
static void LogError(SmtpAgentSettings settings, Exception ex) { // if we blow up here we should write out to the EventLog w/o any logger // dependencies, etc... string source = settings == null || settings.LogSettings == null || string.IsNullOrEmpty(settings.LogSettings.EventLogSource) ? null : settings.LogSettings.EventLogSource; EventLogHelper.WriteError(source, "While loading SmtpAgent settings - " + ex); }
///<summary> /// Initialize the global inversion of control reference with the <paramref name="sectionName"/>. /// <see cref="IoC"/> allows us to drop in a different inversion of control container /// that will vary between different companies' implementations of the gateway and agent. ///</summary> ///<param name="sectionName">The container to use as the resolver</param> ///<returns>Returns a reference to the resolver so it can be used in method chaining.</returns> ///<exception cref="ArgumentNullException">Throw if <paramref name="sectionName"/> was null</exception> public static IDependencyResolver Initialize(string sectionName) { try { IocContainerSection section = IocContainerSection.Load(sectionName); IDependencyContainer container = section.CreateContainer(); return(container.RegisterFromConfig()); } catch (Exception ex) { EventLogHelper.WriteError("While initializing container", ex.ToString()); throw; } }
internal static void WriteEventLog(Exception ex) { EventLogHelper.WriteError(EventLogSourceName, ex.ToString()); }