コード例 #1
0
ファイル: LoggingConfiguration.cs プロジェクト: ucaupa/NLog
        /// <summary>
        /// Validates the configuration.
        /// </summary>
        internal void ValidateConfig()
        {
            var roots = new List <object>();

            foreach (LoggingRule rule in GetLoggingRulesThreadSafe())
            {
                roots.Add(rule);
            }

            var targetList = GetAllTargetsThreadSafe();

            foreach (Target target in targetList)
            {
                roots.Add(target);
            }

            _configItems = ObjectGraphScanner.FindReachableObjects <object>(true, roots.ToArray());

            // initialize all config items starting from most nested first
            // so that whenever the container is initialized its children have already been
            InternalLogger.Info("Found {0} configuration items", _configItems.Count);

            foreach (object o in _configItems)
            {
                PropertyHelper.CheckRequiredParameters(o);
            }
        }
コード例 #2
0
ファイル: LoggingConfiguration.cs プロジェクト: pysco68/NLog
        /// <summary>
        /// Validates the configuration.
        /// </summary>
        internal void ValidateConfig()
        {
            var roots = new List <object>();

            var loggingRules = this.LoggingRules.ToList();

            foreach (LoggingRule rule in loggingRules)
            {
                roots.Add(rule);
            }

            var targetList = this.targets.Values.ToList();

            foreach (Target target in targetList)
            {
                roots.Add(target);
            }

            this.configItems = ObjectGraphScanner.FindReachableObjects <object>(roots.ToArray());

            // initialize all config items starting from most nested first
            // so that whenever the container is initialized its children have already been
            InternalLogger.Info("Found {0} configuration items", this.configItems.Length);

            foreach (object o in this.configItems)
            {
                PropertyHelper.CheckRequiredParameters(o);
            }
        }
コード例 #3
0
        /// <summary>
        /// Validates the configuration.
        /// </summary>
        internal void ValidateConfig()
        {
            var roots = new List <object>();

            foreach (LoggingRule rule in GetLoggingRulesThreadSafe())
            {
                roots.Add(rule);
            }

            var targetList = GetAllTargetsThreadSafe();

            foreach (Target target in targetList)
            {
                roots.Add(target);
            }

            _configItems = ObjectGraphScanner.FindReachableObjects <object>(true, roots.ToArray());

            InternalLogger.Info("Validating config: {0}", this);

            foreach (object o in _configItems)
            {
                PropertyHelper.CheckRequiredParameters(o);
            }
        }
コード例 #4
0
 private void FindAllLayouts()
 {
     this.allLayouts = ObjectGraphScanner.FindReachableObjects <Layout>(this);
     InternalLogger.Trace("{0} has {1} layouts", this, this.allLayouts.Count);
     this.allLayoutsAreThreadAgnostic = allLayouts.All(layout => layout.ThreadAgnostic);
     this.StackTraceUsage             = allLayouts.DefaultIfEmpty().Max(layout => layout == null ? StackTraceUsage.None : layout.StackTraceUsage);
     this.scannedForLayouts           = true;
 }
コード例 #5
0
 private void FindAllLayouts()
 {
     this.allLayouts = new List<Layout>(ObjectGraphScanner.FindReachableObjects<Layout>(this));
     InternalLogger.Trace("{0} has {1} layouts", this, this.allLayouts.Count);
     bool foundNotThreadAgnostic = false;
     foreach (Layout layout in this.allLayouts)
     {
         if (!layout.IsThreadAgnostic)
         {
             foundNotThreadAgnostic = true;
             break;
         }
     }
     this.allLayoutsAreThreadAgnostic = !foundNotThreadAgnostic;
     this.scannedForLayouts = true;
 }
コード例 #6
0
 private void FindAllLayouts()
 {
     _allLayouts = ObjectGraphScanner.FindReachableObjects <Layout>(false, this);
     InternalLogger.Trace("{0} has {1} layouts", this, _allLayouts.Count);
     _allLayoutsAreThreadAgnostic = _allLayouts.All(layout => layout.ThreadAgnostic);
     if (!_allLayoutsAreThreadAgnostic)
     {
         _allLayoutsAreThreadSafe = _allLayouts.All(layout => layout.ThreadSafe);
     }
     else
     {
         _oneLayoutIsMutableUnsafe = _allLayouts.Any(layout => layout.MutableUnsafe);
     }
     StackTraceUsage    = _allLayouts.DefaultIfEmpty().Max(layout => layout?.StackTraceUsage ?? StackTraceUsage.None);
     _scannedForLayouts = true;
 }
コード例 #7
0
        private static bool CanBeConvertedToLiteral(LayoutRenderer lr)
        {
            foreach (IRenderable renderable in ObjectGraphScanner.FindReachableObjects <IRenderable>(true, lr))
            {
                if (renderable.GetType() == typeof(SimpleLayout))
                {
                    continue;
                }

                if (!renderable.GetType().IsDefined(typeof(AppDomainFixedOutputAttribute), false))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #8
0
        /// <summary>
        /// Validates the configuration.
        /// </summary>
        internal void ValidateConfig()
        {
            var roots = new List <object>();

            foreach (LoggingRule rule in GetLoggingRulesThreadSafe())
            {
                roots.Add(rule);
            }

            var targetList = GetAllTargetsThreadSafe();

            foreach (Target target in targetList)
            {
                roots.Add(target);
            }

            _configItems = ObjectGraphScanner.FindReachableObjects <object>(true, roots.ToArray());

            InternalLogger.Info("Validating config: {0}", this);

            foreach (object o in _configItems)
            {
                try
                {
                    if (o is ISupportsInitialize)
                    {
                        continue;   // Target + Layout + LayoutRenderer validate on Initialize()
                    }
                    PropertyHelper.CheckRequiredParameters(o);
                }
                catch (Exception ex)
                {
                    if (ex.MustBeRethrown())
                    {
                        throw;
                    }
                }
            }
        }
コード例 #9
0
ファイル: Target.cs プロジェクト: leomicheloni/NLog
 private void FindAllLayouts()
 {
     this.allLayouts = new List <Layout>(ObjectGraphScanner.FindReachableObjects <Layout>(this));
     InternalLogger.Trace("{0} has {1} layouts", this, this.allLayouts.Count);
     this.scannedForLayouts = true;
 }
コード例 #10
0
 /// <summary>
 /// Initializes the target. Can be used by inheriting classes
 /// to initialize logging.
 /// </summary>
 protected virtual void InitializeTarget()
 {
     this.allLayouts = new List <Layout>(ObjectGraphScanner.FindReachableObjects <Layout>(this));
     InternalLogger.Trace("{0} has {1} layouts", this, this.allLayouts.Count);
 }
コード例 #11
0
 private void GetAllLayouts()
 {
     allLayouts = new List <Layout>(ObjectGraphScanner.FindReachableObjects <Layout>(this));
     InternalLogger.Trace("{0} has {1} layouts", this, allLayouts.Count);
 }