private static void InitialiseExceptionHandlerStreams() { if (false == m_ExceptionLoggingInfo.IsLoggingEnabled) { return; } if (m_ExceptionLoggingInfo.LogSink.ToUpper() == "FILE") { if (!m_isFileStreamInitialized) { ExceptionLogFilePolicy exceptionLogFilePolicy = null; FileStream logFileStream = null; try { exceptionLogFilePolicy = new ExceptionLogFilePolicy(LoggingConstants.CONS_EXCEPTIONLOGGING_FILE_BASE_NAME, m_ExceptionLoggingInfo.FileSizeInMB, LoggingConstants.CONS_TOTAL_EXCEPTIONLOGGING_FILES); logFileStream = exceptionLogFilePolicy.GetLogFileStream(); m_Logger = new FlatFileLogger(logFileStream); m_isFileStreamInitialized = true; } catch (Exception ex) { m_ExceptionLoggingInfo.IsLoggingEnabled = false; if (logFileStream != null) { logFileStream.Dispose(); } throw ex; } } } else if (m_ExceptionLoggingInfo.LogSink.ToUpper() == "EVENTLOG") { if (!m_isEventlogInitialized) { try { m_Logger = new FormattedEventLogger(); m_isEventlogInitialized = true; } catch (Exception ex) { m_ExceptionLoggingInfo.IsLoggingEnabled = false; throw ex; } } } else { //TODO: Throw some sensible error throw new OMEException("999", "Logging Exception", CriticalityLevel.HIGH); } }
private static void InitialiseExceptionHandlerStreams() { if (false == m_ExceptionLoggingInfo.IsLoggingEnabled) return; if (m_ExceptionLoggingInfo.LogSink.ToUpper() == "FILE") { if (!m_isFileStreamInitialized) { ExceptionLogFilePolicy exceptionLogFilePolicy = null; FileStream logFileStream = null; try { exceptionLogFilePolicy = new ExceptionLogFilePolicy(LoggingConstants.CONS_EXCEPTIONLOGGING_FILE_BASE_NAME, m_ExceptionLoggingInfo.FileSizeInMB, LoggingConstants.CONS_TOTAL_EXCEPTIONLOGGING_FILES); logFileStream = exceptionLogFilePolicy.GetLogFileStream(); m_Logger = new FlatFileLogger(logFileStream); m_isFileStreamInitialized = true; } catch (Exception ex) { m_ExceptionLoggingInfo.IsLoggingEnabled = false; if (logFileStream != null) logFileStream.Dispose(); throw ex; } } } else if (m_ExceptionLoggingInfo.LogSink.ToUpper() == "EVENTLOG") { if (!m_isEventlogInitialized) { try { m_Logger = new FormattedEventLogger(); m_isEventlogInitialized = true; } catch (Exception ex) { m_ExceptionLoggingInfo.IsLoggingEnabled = false; throw ex; } } } else { //TODO: Throw some sensible error throw new OMEException("999", "Logging Exception", CriticalityLevel.HIGH); } }