コード例 #1
0
        //public string Endpoint { get; set; }

        //public PatternLayout Environment { get; set; }

        //public PatternLayout Platform { get; set; }

        //public PatternLayout Language { get; set; }

        //public PatternLayout Framework { get; set; }

        #endregion

        #region Override implementation of AppenderSkeleton

        /// <summary>
        /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
        /// </summary>
        /// <param name="loggingEvent">The event to log.</param>
        /// <remarks>
        /// <para>
        /// Writes the event to Rollbar.
        /// </para>
        /// <para>
        /// The format of the output will depend on the appender's layout.
        /// </para>
        /// </remarks>
        override protected void Append(LoggingEvent loggingEvent)
        {
            var client = new RollbarClient(this.AccessToken);

            client.RequestStarting += this.RollbarClient_RequestStarting;
            client.RequestCompleted += this.RollbarClient_RequestCompleted;

            //if (!string.IsNullOrWhiteSpace(this.Endpoint))
            //    client.Configuration.Endpoint = this.Endpoint;

            //if (this.Environment != null)
            //    client.Configuration.Environment = this.Environment.Format(loggingEvent);

            //if (this.Platform != null)
            //    client.Configuration.Platform = this.Platform.Format(loggingEvent);

            //if (this.Language != null)
            //    client.Configuration.Language = this.Language.Format(loggingEvent);

            var notice = loggingEvent.ExceptionObject != null
                ? client.NoticeBuilder.CreateExceptionNotice(loggingEvent.ExceptionObject)
                : client.NoticeBuilder.CreateMessageNotice(base.RenderLoggingEvent(loggingEvent));

            notice.Level = ConvertLogLevel(loggingEvent.Level);
            //notice.Title = string.Empty;

            client.Send(notice);
        }
コード例 #2
0
        public void RawLogToRollbar()
        {
            var client = new RollbarClient("3203880e148b43b4b1a14430fb41957a");

            client.RequestStarting += this.RollbarClient_RequestStarting;
            client.RequestCompleted += this.RollbarClient_RequestCompleted;

            var notice = client.NoticeBuilder.CreateMessageNotice("This is a test message");

            notice.Level = "error";
            notice.Title = "Test Message";

            client.Send(notice);

            while (wait) { }
        }