예제 #1
0
        private void Initialize()
        {
            KeySet loggerSettings = KeySetConfiguration.Config(LOGGER_SECTION);

            if (loggerSettings == null)
            {
                throw new ConfigurationErrorsException(string.Format(CultureInfo.CurrentCulture, ResourceData.MissingConfigSetting, LOGGER_SECTION));
            }

            _applicationId             = int.Parse(loggerSettings.Keys[APPLICATION_ID_KEY].Value, CultureInfo.InvariantCulture);
            _logFrameworkTraceMessages = string.Compare(loggerSettings.Keys[LOG_FRAMEWORK_TRACE_MESSAGES_KEY].Value, "true", true, CultureInfo.InvariantCulture) == 0 ? true : false;

            LoggerTraceListener listener = new LoggerTraceListener();

            if (Trace.Listeners.Contains(listener) == false)
            {
                Trace.Listeners.Add(listener);
            }

            _logFailuresToDisk = string.Compare(loggerSettings.Keys[LOG_FAILURES_TO_DISK_KEY].Value, "true", true, CultureInfo.InvariantCulture) == 0 ? true : false;
            if (_logFailuresToDisk == true)
            {
                _failurePath = loggerSettings.Keys[FAILURE_PATH_KEY].Value;
            }

            _loggingLevels = new LogLevelSettings(loggerSettings);

            _transports = new TransportSettings[loggerSettings.KeySets[TRANSPORTS_KEY].KeySets.Count];

            for (int i = 0; i < loggerSettings.KeySets[TRANSPORTS_KEY].KeySets.Count; i++)
            {
                _transports[i] = new TransportSettings(loggerSettings.KeySets[TRANSPORTS_KEY].KeySets[i]);
            }
        }
예제 #2
0
        public TransportSettings(KeySet transportKeySet)
        {
            if (transportKeySet == null)
            {
                throw new ArgumentNullException("transportKeySet");
            }

            if (string.IsNullOrEmpty(transportKeySet.Name))
            {
                throw new LoggerException(string.Format(CultureInfo.CurrentCulture, ResourceData.InvalidTransportType, ""));
            }

            _transportType = transportKeySet.Name.Trim().ToLowerInvariant();
            _loggingLevels = new LogLevelSettings(transportKeySet);

            for (int i = 0; i < transportKeySet.Keys.Count; i++)
            {
                _configs.Add(transportKeySet.Keys[i].Name, transportKeySet.Keys[i].Value);
            }
        }