//need sync locking in this constructor? /// <summary> /// Private constructor, loads configuration, initializes the internal event queue /// and sets up the flush timer delegate. /// </summary> private Logger() { try { Debug.WriteLine("Creating Logger object.", "Logger.ctor"); m_oLoggerConfig = (LoggerConfig)LoggerUtils.XMLSerializer.DeserializeObjectFromFile(typeof(LoggerConfig), m_sConfigFile); m_qEvents = new Queue(); m_iFlushInterval = m_oLoggerConfig.FlushInterval; m_sAppSourceName = m_oLoggerConfig.AppName; m_oTimerCallback = new TimerCallback(m_oFlushDelegate.Flush); //m_oTimer = new Timer(m_oTimerCallback, null, m_iFlushInterval * 1000, m_iFlushInterval * 1000); //set the logger config object for the handler factory HandlerFactory.SetLoggerConfig(m_oLoggerConfig); } catch (IOException ioExp) { Debug.WriteLine("IOException while creating Logger(ctor). Logger will not log anything!: " + ioExp.Message, "Logger.ctor"); ExceptionWriter("IOException while creating Logger(ctor). Logger will not log anything!", ioExp); } catch (LoggerUtils.XMLSerializerException xmlExp) { Debug.WriteLine("XMLSerializerException while creating Logger(ctor). Logger will not log anything!: " + xmlExp.Message, "Logger.ctor"); ExceptionWriter("XMLSerializerException while creating Logger(ctor). Logger will not log anything!", xmlExp); } catch (Exception exp) { Debug.WriteLine("General exception while creating Logger(ctor). Logger will not log anything!: " + exp.Message, "Logger.ctor"); ExceptionWriter("General exception while creating Logger(ctor). Logger will not log anything!", exp); } }
/// <summary> /// Sets the logger config object. /// </summary> /// <param name="oLoggerConfig"></param> public static void SetLoggerConfig(LoggerConfig oLoggerConfig) { lock (_monitor) { m_oLoggerConfig = oLoggerConfig; } }