private static void EmitFactoryResolverError(IFactoryResolver resolver) { var msg = "The factory resolver " + resolver.GetType().Name + " returned null from GetFactory(). The fallback no operation logger factory will be used instead."; EventLogHelper.WriteEntry(msg, null); }
private static void PerformInitialization() { try { if (_factoryResolver == null) { _factoryResolver = new AppConfigFactoryResolver(); } var factory = _factoryResolver.GetFactory(); if (factory == null) { _initializationState = InitializationState.NOP_Fallback; EmitFactoryResolverError(_factoryResolver); return; } _initializationState = InitializationState.Initialized; EmitSubstituteLoggerWarning(); } catch (Exception ex) { _initializationState = InitializationState.NOP_Fallback; try { EventLogHelper.WriteEntry("Error initializing LoggerFactory. Defaulting to no-operation (NOP) logger implementation.", ex); } catch { } } }
private static void EmitSubstituteLoggerWarning() { var loggerNameList = _tempFactory.GetLoggerNameList(); if (loggerNameList.Length == 0) { return; } var msg = "The following loggers will not work because the were created during the default configuration phase of the underlying logging system: " + string.Join(", ", loggerNameList); EventLogHelper.WriteEntry(msg, null); }