Exemplo n.º 1
0
		/// <summary>
		/// 将日志实体写入到所有Target
		/// </summary>
		/// <param name="entry"></param>
		/// <param name="targets"></param>
		protected override void WriteToTargets(LogEntry entry, IEnumerable<ITarget> targets)
		{
			foreach (var target in targets)
			{
				entry.Logger = _loggerMapping[target];
				target.Write(entry.Clone() as LogEntry);
			}
		}
Exemplo n.º 2
0
        /// <summary>
        /// 格式化日志实体
        /// </summary>
		public string Format(LogEntry entry)
		{
            if (entry == null)
                return "NullEntry";

            StringBuilder sb = new StringBuilder();

            foreach (IPartFormatter formatter in _lineFormatters)
            {
                sb.Append(formatter.Format(entry));
            }

            if (entry.Exception != null)
            {
                sb.Append(Environment.NewLine);
                sb.Append(entry.Exception);
            }

            return sb.ToString();
		}
Exemplo n.º 3
0
		protected virtual void WriteToTargets(LogEntry entry, IEnumerable<ITarget> targets)
		{
			foreach (ITarget target in _targets)
				target.Write(entry);
		}