• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# LoggingEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Append

  protected override void Append (LoggingEvent loggingEvent)
  {
    try
    {
      base.Append (loggingEvent);
      if (maximumEntries == 0)
      {
        return;
      }

      lock (m_eventsList.SyncRoot)
      {
        int elementsToRemove = m_eventsList.Count - maximumEntries;
        if (elementsToRemove > 0)
        {
          UnityEngine.Debug.Log ("Removing " + elementsToRemove + " elements.");
          m_eventsList.RemoveRange (0, elementsToRemove);
        }
      }
    }
    catch(Exception e)
    {
      UnityEngine.Debug.LogError(e);
    }
  }
开发者ID:kimkidae,项目名称:UnityMinaClient,代码行数:25,代码来源:ValionLogAppender.cs


示例2: Push

        public override void Push(LoggingEvent[] loggingEvents)
        {
            if (loggingEvents == null)
                throw new ArgumentNullException("loggingEvents");

            _queue.Enqueue(loggingEvents);
        }
开发者ID:eduardocampano,项目名称:pulsus,代码行数:7,代码来源:AsyncWrapperTarget.cs


示例3: PushingWithNoTargetsShouldThrow

        public void PushingWithNoTargetsShouldThrow()
        {
            var eventDispatcher = new DefaultEventDispatcher();

            var loggingEvent = new LoggingEvent { Text = "Event" };
            Executing.This(() => eventDispatcher.Push(loggingEvent, false)).Should().Throw<InvalidOperationException>();
        }
开发者ID:perikete,项目名称:Pulsus,代码行数:7,代码来源:DefaultEventDispatcherTests.cs


示例4: Push

 public override void Push(LoggingEvent[] loggingEvents)
 {
     foreach (var loggingEvent in loggingEvents)
     {
         Console.WriteLine(Format.Format(loggingEvent));
     }
 }
开发者ID:eduardocampano,项目名称:pulsus,代码行数:7,代码来源:ConsoleTarget.cs


示例5: GetRequest

        protected HttpWebRequest GetRequest(LoggingEvent[] loggingEvents)
        {
            var request = (HttpWebRequest)WebRequest.Create(Url);
            request.KeepAlive = false;
            request.Timeout = 5000;
            request.ServicePoint.ConnectionLeaseTimeout = 5000;
            request.ServicePoint.MaxIdleTime = 5000;
            request.ServicePoint.ConnectionLimit = 50;
            request.Accept = "application/json";
            request.UserAgent = "Pulsus " + Constants.Version;
            request.Method = "POST";
            request.ContentType = "application/json";

            var bytes = GetRequestBody(loggingEvents, Compress);
            request.ContentLength = bytes.Length;
            if (Compress)
                request.Headers.Add("Content-Encoding", "gzip");

            using (var requestStream = request.GetRequestStream())
            {
                requestStream.Write(bytes, 0, bytes.Length);
            }

            return request;
        }
开发者ID:eduardocampano,项目名称:pulsus,代码行数:25,代码来源:ServerTarget.cs


示例6: Post

        public void Post(LoggingEvent[] loggingEvents)
        {
            var request = GetRequest(loggingEvents);

            try
            {
                var response = request.GetResponse() as HttpWebResponse;

                if (response == null)
                    throw new Exception("There was an error posting the server");

                if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.Created && response.StatusCode != HttpStatusCode.Accepted)
                    throw new Exception(string.Format("The server returned a {0} status with the message: {1}", response.StatusCode, response.StatusDescription));
            }
            catch (WebException ex)
            {
                if (ex.Response == null)
                    throw new Exception(string.Format("Response Status: {0}, Description: {1}", ex.Status, ex.Message), ex);

                var responseStream = ex.Response.GetResponseStream();
                if (responseStream == null)
                    throw new Exception("GetResponseStream() returned null", ex);

                var reader = new StreamReader(responseStream);
                var responseContent = reader.ReadToEnd();

                throw new Exception(string.Format("Response Status: {0}, Content: {1}", ex.Status, responseContent), ex);
            }
        }
开发者ID:eduardocampano,项目名称:pulsus,代码行数:29,代码来源:ServerTarget.cs


示例7: AppendLoopOnAppenders

		/// <summary>
		/// Append on on all attached appenders.
		/// </summary>
		/// <param name="loggingEvent">The event being logged.</param>
		/// <returns>The number of appenders called.</returns>
		/// <remarks>
		/// <para>
		/// Calls the <see cref="IAppender.DoAppend" /> method on all 
		/// attached appenders.
		/// </para>
		/// </remarks>
		public int AppendLoopOnAppenders(LoggingEvent loggingEvent) 
		{
			if (loggingEvent == null)
			{
				throw new ArgumentNullException("loggingEvent");
			}

			// m_appenderList is null when empty
			if (m_appenderList == null) 
			{
				return 0;
			}

			if (m_appenderArray == null)
			{
				m_appenderArray = m_appenderList.ToArray();
			}

			foreach(IAppender appender in m_appenderArray)
			{
				try
				{
					appender.DoAppend(loggingEvent);
				}
				catch(Exception ex)
				{
					LogLog.Error(declaringType, "Failed to append to appender [" + appender.Name + "]", ex);
				}
			}
			return m_appenderList.Count;
		}
开发者ID:Jsiegelion,项目名称:ExaminationOnline,代码行数:42,代码来源:AppenderAttachedImpl.cs


示例8: Convert

		/// <summary>
		/// Write the ASP.Net Cache item to the output
		/// </summary>
		/// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
		/// <param name="loggingEvent">The <see cref="LoggingEvent" /> on which the pattern converter should be executed.</param>
		/// <param name="httpContext">The <see cref="HttpContext" /> under which the ASP.Net request is running.</param>
		/// <remarks>
		/// <para>
		/// Writes out the value of a named property. The property name
		/// should be set in the <see cref="Mammothcode.Public.Core.Util.PatternConverter.Option"/>
		/// property.
		/// </para>
		/// </remarks>
		protected override void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext)
		{
		    HttpRequest request = null;
		    try {
			request = httpContext.Request;
		    } catch (HttpException) {
			// likely a case of running in IIS integrated mode
			// when inside an Application_Start event.
			// treat it like a case of the Request
			// property returning null
		    }

			if (request != null)
			{
				if (Option != null)
				{
					WriteObject(writer, loggingEvent.Repository, httpContext.Request.Params[Option]);
				}
				else
				{
					WriteObject(writer, loggingEvent.Repository, httpContext.Request.Params);
				}
			}
			else
			{
				writer.Write(SystemInfo.NotAvailableText);
			}
		}
开发者ID:Jsiegelion,项目名称:ExaminationOnline,代码行数:41,代码来源:AspNetRequestPatternConverter.cs


示例9: EmailTemplateModel

        public EmailTemplateModel(LoggingEvent loggingEvent)
        {
            if (loggingEvent == null)
                throw new ArgumentNullException("loggingEvent");

            LoggingEvent = loggingEvent;
            HttpContextInformation = loggingEvent.GetData<HttpContextInformation>(Constants.DataKeys.HttpContext);
            StackTrace = loggingEvent.GetData<string>(Constants.DataKeys.StackTrace);
            SqlInformation = loggingEvent.GetData<SqlInformation>(Constants.DataKeys.SQL);
            ExceptionInformation = loggingEvent.GetData<ExceptionInformation>(Constants.DataKeys.Exception);

            GeneralSection = new Dictionary<string, object>();
            LoadGeneralSection();

            CustomData = loggingEvent.Data.Where(x => !x.Key.StartsWith("MS_", StringComparison.InvariantCultureIgnoreCase)).ToDictionary(x => x.Key, x => x.Value);
            if (!CustomData.Any())
                CustomData = null;

            RequestSection = new Dictionary<string, object>();
            LoadRequestSection();

            LevelText = Enum.GetName(typeof (LoggingEventLevel), LoggingEvent.Level);
            LevelClass = "green";
            var loggingEventLevelValue = (int) loggingEvent.Level;
            if (loggingEventLevelValue >= 40000 && loggingEventLevelValue <= 60000)
                LevelClass = "yellow";
            else if (loggingEventLevelValue > 60000)
                LevelClass = "red";

            Footer = string.Format(CultureInfo.InvariantCulture, "Pulsus | {0} | {1}", Constants.Version, Constants.WebSite);
        }
开发者ID:eduardocampano,项目名称:pulsus,代码行数:31,代码来源:EmailTemplateModel.cs


示例10: NullDataValueShouldReturnDefaultValue

        public void NullDataValueShouldReturnDefaultValue()
        {
            var loggingEvent = new LoggingEvent();
            loggingEvent.Data.Add("test", null);

            var value = loggingEvent.GetData<string>("test");

            value.Should().Be.Null();
        }
开发者ID:eduardocampano,项目名称:pulsus,代码行数:9,代码来源:LoggingEventTests.cs


示例11: Append

        protected override void Append(LoggingEvent loggingEvent)
        {
            if (string.Empty.Equals(loggingEvent.MessageObject))
                return;

            if (loggingEvent.MessageObject != null)
            {
                Messages.Add(loggingEvent.MessageObject.ToString());
            }
        }
开发者ID:Dreameris,项目名称:.NET-Common-Library,代码行数:10,代码来源:InMemoryMessageAppender.cs


示例12: SerializedDataShoudBeCorrectlyDeserialized

        public void SerializedDataShoudBeCorrectlyDeserialized()
        {
            const string serializedData = "{ \"custom-data\" : { \"StringField\" : \"test\", \"IntField\" : 9 } }";
            var loggingEvent = new LoggingEvent();
            loggingEvent.Data = JsonConvert.DeserializeObject<IDictionary<string, object>>(serializedData);

            var result = loggingEvent.GetData<CustomData>("custom-data");
            result.Should().Not.Be.Null();
            result.StringField.Should().Be("test");
            result.IntField.Should().Be(9);
        }
开发者ID:eduardocampano,项目名称:pulsus,代码行数:11,代码来源:LoggingEventTests.cs


示例13: Decide

 public override FilterDecision Decide(LoggingEvent loggingEvent)
 {
     if (loggingEvent.LoggerName.StartsWith("NServiceBus."))
     {
         if (loggingEvent.Level < Level.Warn)
         {
             return FilterDecision.Deny;
         }
     }
     return FilterDecision.Accept;
 }
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:11,代码来源:Log4NetFiltering.cs


示例14: Convert

		protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
		{
			if (HttpContext.Current == null)
			{
				writer.Write(SystemInfo.NotAvailableText);
			}
			else
			{
				Convert(writer, loggingEvent, HttpContext.Current);
			}
		}
开发者ID:Jsiegelion,项目名称:ExaminationOnline,代码行数:11,代码来源:AspNetPatternConverter.cs


示例15: Convert

		/// <summary>
		/// Write the TimeStamp to the output
		/// </summary>
		/// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
		/// <param name="loggingEvent">the event being logged</param>
		/// <remarks>
		/// <para>
		/// Pass the <see cref="LoggingEvent.TimeStamp"/> to the <see cref="IDateFormatter"/>
		/// for it to render it to the writer.
		/// </para>
		/// <para>
		/// The <see cref="LoggingEvent.TimeStamp"/> passed is in the local time zone, this is converted
		/// to Universal time before it is rendered.
		/// </para>
		/// </remarks>
		/// <seealso cref="DatePatternConverter"/>
		override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
		{
			try 
			{
				m_dateFormatter.FormatDate(loggingEvent.TimeStamp.ToUniversalTime(), writer);
			}
			catch (Exception ex) 
			{
				LogLog.Error(declaringType, "Error occurred while converting date.", ex);
			}
		}
开发者ID:Jsiegelion,项目名称:ExaminationOnline,代码行数:27,代码来源:UtcDatePatternConverter.cs


示例16: Convert

		/// <summary>
		/// Write the ASP.Net HttpContext item to the output
		/// </summary>
		/// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
		/// <param name="loggingEvent">The <see cref="LoggingEvent" /> on which the pattern converter should be executed.</param>
		/// <param name="httpContext">The <see cref="HttpContext" /> under which the ASP.Net request is running.</param>
		/// <remarks>
		/// <para>
		/// Writes out the value of a named property. The property name
		/// should be set in the <see cref="Mammothcode.Public.Core.Util.PatternConverter.Option"/>
		/// property.
		/// </para>
		/// </remarks>
		protected override void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext)
		{
			if (Option != null)
			{
				WriteObject(writer, loggingEvent.Repository, httpContext.Items[Option]);
			}
			else
			{
				WriteObject(writer, loggingEvent.Repository, httpContext.Items);
			}
		}
开发者ID:Jsiegelion,项目名称:ExaminationOnline,代码行数:24,代码来源:AspNetContextPatternConverter.cs


示例17: LogEvents

		public void LogEvents (LoggingEvent [] events)
		{
			if (events != null) {
				foreach (LoggingEvent logEvent in events) {
					string logFile = Path.Combine (AppDomain.CurrentDomain.BaseDirectory,
						"log");
					using (StreamWriter sw = File.AppendText (logFile)) {
						sw.WriteLine (logEvent.Message);
					}
				}
			}
		}
开发者ID:mono,项目名称:gert,代码行数:12,代码来源:server.cs


示例18: Enqueue

        public void Enqueue(LoggingEvent[] loggingEvents)
        {
            lock (_locker)
            {
                // ignore new logging events
                if (_loggingEventQueue.Count >= MaxQueueSize)
                    return;

                foreach (var loggingEvent in loggingEvents)
                    _loggingEventQueue.Enqueue(loggingEvent);
            }
        }
开发者ID:eduardocampano,项目名称:pulsus,代码行数:12,代码来源:LoggingEventQueue.cs


示例19: Log

 public void Log(LoggingEvent.LogLevels logLevel, string processName, string subProcessName, string logCategory, string logMessage)
 {
     LoggingEvent logEvent = new LoggingEvent();
     logEvent.LogLevel = logLevel;
     logEvent.DateTimeSource = DateTime.Now;
     logEvent.ProcessName = processName;
     logEvent.SubProcessName = subProcessName;
     logEvent.LogCategory = logCategory;
     logEvent.LogMessage = logMessage;
     m_Queue.Enqueue(logEvent);
     m_EventContinue.Set();
 }
开发者ID:mickomicko5573,项目名称:wcf-pubsub-logger,代码行数:12,代码来源:LogPublisher.cs


示例20: Append

    protected override void Append(LoggingEvent loggingEvent)
    {
        EventHandler<OnLog4NetLogEventArgs> temp = OnLog;

        if (temp != null)
        {
            lock (_syncRoot)
            {
                temp(null, new OnLog4NetLogEventArgs(loggingEvent));
            }
        }
    }
开发者ID:johnsmith9264,项目名称:MyChat,代码行数:12,代码来源:Log4NetLogEventSourceAppender.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LoggingLevel类代码示例发布时间:2022-05-24
下一篇:
C# Logging类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap