Exemplo n.º 1
0
        public bool IsEqualTo(LogSystemConfiguration systemConfiguration)
        {
            if (systemConfiguration == null)
            {
                return(false);
            }

            if (string.Equals(Name, systemConfiguration.Name, StringComparison.Ordinal) == false)
            {
                return(false);
            }

            if (_fields.Count != systemConfiguration._fields.Count)
            {
                return(false);
            }

            foreach (var field in _fields)
            {
                var otherField = systemConfiguration.FindField(field.Name);

                if (field.IsEqualTo(otherField) == false)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public LogConfiguration(string configurationRoot, ILogger <LogConfiguration> logger)
        {
            _readOnlyCollection = _logConfigurations.AsReadOnly();

            foreach (var logConfigPath in Directory.EnumerateFiles(configurationRoot, "*.json"))
            {
                try
                {
                    var systemConfiguration = LogSystemConfiguration.ReadFromFile(logConfigPath);

                    _systemConfigurationsDictionary.Add(systemConfiguration.Name, systemConfiguration);
                    _logConfigurations.Add(systemConfiguration);
                }
                catch (Exception e)
                {
                    logger.LogError(e, $"Can not read log configuration file '{logConfigPath}'");
                }
            }
        }