当前位置: 首页>>代码示例>>C#>>正文


C# Targets.Target类代码示例

本文整理汇总了C#中NLog.Targets.Target的典型用法代码示例。如果您正苦于以下问题:C# Target类的具体用法?C# Target怎么用?C# Target使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Target类属于NLog.Targets命名空间,在下文中一共展示了Target类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoggingRule

 /// <summary>
 /// Create a new <see cref="LoggingRule" /> with a <paramref name="minLevel"/> and  <paramref name="maxLevel"/> which writes to <paramref name="target"/>.
 /// </summary>
 /// <param name="loggerNamePattern">Logger name pattern. It may include the '*' wildcard at the beginning, at the end or at both ends.</param>
 /// <param name="minLevel">Minimum log level needed to trigger this rule.</param>
 /// <param name="maxLevel">Maximum log level needed to trigger this rule.</param>
 /// <param name="target">Target to be written to when the rule matches.</param>
 public LoggingRule(string loggerNamePattern, LogLevel minLevel, LogLevel maxLevel, Target target)
     : this()
 {
     this.LoggerNamePattern = loggerNamePattern;
     this.Targets.Add(target);
     EnableLoggingForLevels(minLevel, maxLevel);
 }
开发者ID:CjShu,项目名称:LeagueSharp.SDKEx,代码行数:14,代码来源:LoggingRule.cs

示例2: ConfigureForTargetLogging

 /// <summary>
 /// Configures NLog for to log to the specified target so that all messages 
 /// above and including the specified level are output.
 /// </summary>
 /// <param name="target">The target to log all messages to.</param>
 /// <param name="minLevel">The minimal logging level.</param>
 public static void ConfigureForTargetLogging(Target target, LogLevel minLevel)
 {
     LoggingConfiguration config = new LoggingConfiguration();
     LoggingRule rule = new LoggingRule("*", minLevel, target);
     config.LoggingRules.Add(rule);
     LogManager.Configuration = config;
 }
开发者ID:304NotModified,项目名称:NLog-1,代码行数:13,代码来源:SimpleConfigurator.cs

示例3: LoggingRule

 /// <summary>
 /// Initializes a new instance of the <see cref="LoggingRule" /> class.
 /// </summary>
 /// <param name="loggerNamePattern">Logger name pattern. It may include the '*' wildcard at the beginning, at the end or at both ends.</param>
 /// <param name="minLevel">Minimum log level needed to trigger this rule.</param>
 /// <param name="target">Target to be written to when the rule matches.</param>
 public LoggingRule(string loggerNamePattern, LogLevel minLevel, Target target)
 {
     this.Filters = new List<Filter>();
     this.ChildRules = new List<LoggingRule>();
     this.Targets = new List<Target>();
     this.LoggerNamePattern = loggerNamePattern;
     this.Targets.Add(target);
     for (int i = minLevel.Ordinal; i <= LogLevel.MaxLevel.Ordinal; ++i)
     {
         this.EnableLoggingForLevel(LogLevel.FromOrdinal(i));
     }
 }
开发者ID:mattcuba,项目名称:practicesharp,代码行数:18,代码来源:LoggingRule.cs

示例4: AspNetBufferingTargetWrapper

 /// <summary>
 /// Initializes a new instance of the <see cref="AspNetBufferingTargetWrapper" /> class.
 /// </summary>
 /// <param name="wrappedTarget">The wrapped target.</param>
 /// <param name="bufferSize">Size of the buffer.</param>
 public AspNetBufferingTargetWrapper(Target wrappedTarget, int bufferSize)
 {
     WrappedTarget = wrappedTarget;
     BufferSize = bufferSize;
     GrowBufferAsNeeded = true;
 }
开发者ID:epignosisx,项目名称:NLog.Web,代码行数:11,代码来源:AspNetBufferingTargetWrapper.cs

示例5: Add

 /// <summary>
 /// Adds an element with the specified key and value to this TargetDictionary.
 /// </summary>
 /// <param name="key">
 /// The string key of the element to add.
 /// </param>
 /// <param name="value">
 /// The Target value of the element to add.
 /// </param>
 public virtual void Add(string key, Target value)
 {
     this.Dictionary.Add(key, value);
 }
开发者ID:pallmall,项目名称:WCell,代码行数:13,代码来源:TargetDictionary.cs

示例6: TargetWithFilterChain

 public TargetWithFilterChain(Target a, FilterCollection filterChain)
 {
     _target = a;
     _filterChain = filterChain;
     _needsStackTrace = 0;
 }
开发者ID:tdhieu,项目名称:openvss,代码行数:6,代码来源:TargetWithFilterChain.cs

示例7: WrapWithAsyncTargetWrapper

 private static Target WrapWithAsyncTargetWrapper(Target target)
 {
     var asyncTargetWrapper = new AsyncTargetWrapper();
     asyncTargetWrapper.WrappedTarget = target;
     asyncTargetWrapper.Name = target.Name;
     target.Name = target.Name + "_wrapped";
     InternalLogger.Debug("Wrapping target '{0}' with AsyncTargetWrapper and renaming to '{1}", asyncTargetWrapper.Name, target.Name);
     target = asyncTargetWrapper;
     return target;
 }
开发者ID:shadowca,项目名称:NLog,代码行数:10,代码来源:XmlLoggingConfiguration.cs

示例8: TargetWithFilterChain

 /// <summary>
 /// Initializes a new instance of the <see cref="TargetWithFilterChain" /> class.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="filterChain">The filter chain.</param>
 public TargetWithFilterChain(Target target, IList<Filter> filterChain)
 {
     this.Target = target;
     this.FilterChain = filterChain;
 }
开发者ID:CharlieBP,项目名称:NLog,代码行数:10,代码来源:TargetWithFilterChain.cs

示例9: TargetWithFilterChain

 /// <summary>
 /// Initializes a new instance of the <see cref="TargetWithFilterChain" /> class.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="filterChain">The filter chain.</param>
 public TargetWithFilterChain(Target target, IList<Filter> filterChain)
 {
     this.Target = target;
     this.FilterChain = filterChain;
     this.stackTraceUsage = StackTraceUsage.None;
 }
开发者ID:shadowca,项目名称:NLog,代码行数:11,代码来源:TargetWithFilterChain.cs

示例10: WrapWithDefaultWrapper

        private Target WrapWithDefaultWrapper(Target t, XmlReader reader)
        {
            string wrapperType;

            if (!this.TryGetCaseInsensitiveAttribute(reader, "type", out wrapperType))
            {
                // TODO - add error handling
            }

            Target wrapperTargetInstance = this.nlogFactories.TargetFactory.CreateInstance(wrapperType);
            WrapperTargetBase wtb = wrapperTargetInstance as WrapperTargetBase;
            if (wtb == null)
            {
                throw new NLogConfigurationException("Target type specified on <default-wrapper /> is not a wrapper.");
            }

            this.ParseTargetElement(wrapperTargetInstance, reader);
            while (wtb.WrappedTarget != null)
            {
                wtb = wtb.WrappedTarget as WrapperTargetBase;
                if (wtb == null)
                {
                    throw new NLogConfigurationException("Child target type specified on <default-wrapper /> is not a wrapper.");
                }
            }

            wtb.WrappedTarget = t;
            wrapperTargetInstance.Name = t.Name;
            t.Name = t.Name + "_wrapped";

            InternalLogger.Debug("Wrapping target '{0}' with '{1}' and renaming to '{2}", wrapperTargetInstance.Name, wrapperTargetInstance.GetType().Name, t.Name);
            return wrapperTargetInstance;
        }
开发者ID:igalse,项目名称:NLog,代码行数:33,代码来源:XmlLoggingConfiguration.cs

示例11: WrapWithAsyncTarget

 private Target WrapWithAsyncTarget(Target t)
 {
     AsyncTargetWrapper atw = new AsyncTargetWrapper();
     atw.WrappedTarget = t;
     atw.Name = t.Name;
     t.Name = t.Name + "_wrapped";
     InternalLogger.Debug("Wrapping target '{0}' with AsyncTargetWrapper and renaming to '{1}", atw.Name, t.Name);
     return atw;
 }
开发者ID:igalse,项目名称:NLog,代码行数:9,代码来源:XmlLoggingConfiguration.cs

示例12: ParseTargetElement

        private void ParseTargetElement(Target target, XmlReader reader)
        {
            InternalLogger.Trace("ParseTargetElement name={0} type={1}", reader.GetAttribute("name"), reader.GetAttribute("type"));

            var compound = target as CompoundTargetBase;
            var wrapper = target as WrapperTargetBase;

            this.ConfigureObjectFromAttributes(target, reader, this.variables, true);

            if (!reader.IsEmptyElement)
            {
                while (this.MoveToNextElement(reader))
                {
                    string name = reader.LocalName.ToLower(CultureInfo.InvariantCulture);

                    if (compound != null)
                    {
                        if (name == "target" || name == "wrapper" || name == "wrapper-target" || name == "compound-target")
                        {
                            string type;

                            if (!this.TryGetCaseInsensitiveAttribute(reader, "type", out type))
                            {
                                throw new NLogConfigurationException("Missing 'type' attribute on <" + name + " />");
                            }

                            Target newTarget = this.nlogFactories.TargetFactory.CreateInstance(type);
                            if (newTarget != null)
                            {
                                this.ParseTargetElement(newTarget, reader);
                                if (newTarget.Name != null)
                                {
                                    // if the new target has name, register it
                                    AddTarget(newTarget.Name, newTarget);
                                }

                                compound.Targets.Add(newTarget);
                            }

                            continue;
                        }
                    }

                    if (wrapper != null)
                    {
                        if (name == "target" || name == "wrapper" || name == "wrapper-target" || name == "compound-target")
                        {
                            string type;

                            if (!this.TryGetCaseInsensitiveAttribute(reader, "type", out type))
                            {
                                throw new NLogConfigurationException("Missing 'type' attribute on <" + name + " />");
                            }

                            Target newTarget = this.nlogFactories.TargetFactory.CreateInstance(type);
                            if (newTarget != null)
                            {
                                this.ParseTargetElement(newTarget, reader);
                                if (newTarget.Name != null)
                                {
                                    // if the new target has name, register it
                                    AddTarget(newTarget.Name, newTarget);
                                }

                                if (wrapper.WrappedTarget != null)
                                {
                                    throw new NLogConfigurationException("Wrapped target already defined.");
                                }

                                wrapper.WrappedTarget = newTarget;
                            }

                            continue;
                        }
                    }

                    this.SetPropertyFromElement(target, reader);
                }
            }
        }
开发者ID:igalse,项目名称:NLog,代码行数:80,代码来源:XmlLoggingConfiguration.cs

示例13: WrapWithDefaultWrapper

        private Target WrapWithDefaultWrapper(Target t, NLogXmlElement defaultParameters)
        {
            string wrapperType = StripOptionalNamespacePrefix(defaultParameters.GetRequiredAttribute("type"));

            Target wrapperTargetInstance = this.ConfigurationItemFactory.Targets.CreateInstance(wrapperType);
            WrapperTargetBase wtb = wrapperTargetInstance as WrapperTargetBase;
            if (wtb == null)
            {
                throw new NLogConfigurationException("Target type specified on <default-wrapper /> is not a wrapper.");
            }

            this.ParseTargetElement(wrapperTargetInstance, defaultParameters);
            while (wtb.WrappedTarget != null)
            {
                wtb = wtb.WrappedTarget as WrapperTargetBase;
                if (wtb == null)
                {
                    throw new NLogConfigurationException("Child target type specified on <default-wrapper /> is not a wrapper.");
                }
            }

            wtb.WrappedTarget = t;
            wrapperTargetInstance.Name = t.Name;
            t.Name = t.Name + "_wrapped";

            InternalLogger.Debug("Wrapping target '{0}' with '{1}' and renaming to '{2}", wrapperTargetInstance.Name, wrapperTargetInstance.GetType().Name, t.Name);
            return wrapperTargetInstance;
        }
开发者ID:shadowca,项目名称:NLog,代码行数:28,代码来源:XmlLoggingConfiguration.cs

示例14: AddTarget

        /// <summary>
        /// Registers the specified target object under a given name.
        /// </summary>
        /// <param name="name">
        /// Name of the target.
        /// </param>
        /// <param name="target">
        /// The target object.
        /// </param>
        public void AddTarget(string name, Target target)
        {
            if (name == null)
            {
                throw new ArgumentException("Target name cannot be null", "name");
            }

            InternalLogger.Debug("Registering target {0}: {1}", name, target.GetType().FullName);
            this.targets[name] = target;
        }
开发者ID:mattcuba,项目名称:practicesharp,代码行数:19,代码来源:LoggingConfiguration.cs

示例15: ParseTargetElement

        private void ParseTargetElement(Target target, NLogXmlElement targetElement)
        {
            var compound = target as CompoundTargetBase;
            var wrapper = target as WrapperTargetBase;

            this.ConfigureObjectFromAttributes(target, targetElement, true);

            foreach (var childElement in targetElement.Children)
            {
                string name = childElement.LocalName;

                if (compound != null)
                {
                    if (IsTargetRefElement(name))
                    {
                        string targetName = childElement.GetRequiredAttribute("name");
                        Target newTarget = this.FindTargetByName(targetName);
                        if (newTarget == null)
                        {
                            throw new NLogConfigurationException("Referenced target '" + targetName + "' not found.");
                        }

                        compound.Targets.Add(newTarget);
                        continue;
                    }

                    if (IsTargetElement(name))
                    {
                        string type = StripOptionalNamespacePrefix(childElement.GetRequiredAttribute("type"));

                        Target newTarget = this.ConfigurationItemFactory.Targets.CreateInstance(type);
                        if (newTarget != null)
                        {
                            this.ParseTargetElement(newTarget, childElement);
                            if (newTarget.Name != null)
                            {
                                // if the new target has name, register it
                                AddTarget(newTarget.Name, newTarget);
                            }

                            compound.Targets.Add(newTarget);
                        }

                        continue;
                    }
                }

                if (wrapper != null)
                {
                    if (IsTargetRefElement(name))
                    {
                        string targetName = childElement.GetRequiredAttribute("name");
                        Target newTarget = this.FindTargetByName(targetName);
                        if (newTarget == null)
                        {
                            throw new NLogConfigurationException("Referenced target '" + targetName + "' not found.");
                        }

                        wrapper.WrappedTarget = newTarget;
                        continue;
                    }

                    if (IsTargetElement(name))
                    {
                        string type = StripOptionalNamespacePrefix(childElement.GetRequiredAttribute("type"));

                        Target newTarget = this.ConfigurationItemFactory.Targets.CreateInstance(type);
                        if (newTarget != null)
                        {
                            this.ParseTargetElement(newTarget, childElement);
                            if (newTarget.Name != null)
                            {
                                // if the new target has name, register it
                                AddTarget(newTarget.Name, newTarget);
                            }

                            if (wrapper.WrappedTarget != null)
                            {
                                throw new NLogConfigurationException("Wrapped target already defined.");
                            }

                            wrapper.WrappedTarget = newTarget;
                        }

                        continue;
                    }
                }

                this.SetPropertyFromElement(target, childElement);
            }
        }
开发者ID:shadowca,项目名称:NLog,代码行数:91,代码来源:XmlLoggingConfiguration.cs


注:本文中的NLog.Targets.Target类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。