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

C# LogEntry类代码示例

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

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



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

示例1: WhenLogging_ThenLogWriterWritesToTheInjectedStack

        public void WhenLogging_ThenLogWriterWritesToTheInjectedStack()
        {
            var logEntry = new LogEntry() { Message = "message" };
            this.logWriter.Write(logEntry);

            Assert.AreSame(logEntry, this.traceListener.tracedData);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:7,代码来源:LogWriterInjectionFixture.cs


示例2: if

 void ILogOutput.Write(LogEntry entry)
 {
     if (entry.Type == LogMessageType.Error)
         this.lastErrorMessage = entry.Message;
     else if (entry.Type == LogMessageType.Warning)
         this.lastWarningMessage = entry.Message;
 }
开发者ID:SirePi,项目名称:duality,代码行数:7,代码来源:TestingLogOutput.cs


示例3: Write

        public override void Write(LogEntry entry)
        {
            string caller;
            if (UseStackFrame)
            {
                var frame = GetStackFrame();
                caller = frame.GetMethod().ReflectedType.Name + "." +
                             frame.GetMethod().Name + "():" + frame.GetFileLineNumber();
            }
            else
            {
                caller = LoggedType.Namespace ?? "";
            }

            var color = Console.ForegroundColor;
            Console.ForegroundColor = GetColor(entry.LogLevel);
            Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " " + caller.PadRight(50) +
                              entry.LogLevel.ToString().PadRight(10) + entry.Message);

            if (entry.Exception != null)
            {
                var sb = new StringBuilder();
                BuildExceptionDetails(entry.Exception, 4, sb);
                Console.WriteLine(sb.ToString());
            }


            Console.ForegroundColor = color;
        }
开发者ID:jorgenlidholm,项目名称:Griffin.Framework,代码行数:29,代码来源:ConsoleLogger.cs


示例4: LogEntry_InnerException_DetailsFromInnerException

 public void LogEntry_InnerException_DetailsFromInnerException()
 {
     const string InnerExceptionMessage = "() Inner exception message.";
     const string OuterExceptionMessage = ")( Outer exception message.";
     try
     {
         try
         {
             throw new Exception(InnerExceptionMessage);
         }
         catch (Exception innerException)
         {
             throw new Exception(OuterExceptionMessage, innerException);
         }
     }
     catch (Exception outerException)
     {
         var logEntry = new LogEntry(
             LogType.Error,
             "test",
             outerException,
             null);
         Assert.AreEqual(InnerExceptionMessage, logEntry.ExceptionMessage);
     }
 }
开发者ID:uncas,项目名称:core,代码行数:25,代码来源:LogEntryTests.cs


示例5: Write

 public void Write(LogEntry entry)
 {
     if (Enabled)
     {
         FileStreamWriter.Write(Serializer.Serialize(entry));
     }
 }
开发者ID:rtaylornc,项目名称:IntelliMediaCore,代码行数:7,代码来源:FileLogger.cs


示例6: MessageMarkup

    public object[] MessageMarkup(LogEntry logEntry, int index)
    {
        if (!logEntry.Message.Contains("\n"))
        {
            string encodedMessage = EncodeXml10InvalidCharacters(logEntry.Message);
            return new object[] { encodedMessage };
        }

        string[] lines = EncodeXml10InvalidCharacters(logEntry.Message).Trim().Split('\n');

        if (lines.Length < 7)
        {
            return new object[]
            {
                new XElement("pre", EncodeXml10InvalidCharacters(logEntry.Message.Replace("\n", "")))
            };
        }

        return new object[]
        {
            PreTag(lines, 0, 2),
            new XElement("a",
                new XAttribute("id", "a" + index),
                new XAttribute("href", "#"),
                new XAttribute("onclick", string.Format("document.getElementById('log{0}').style.display = 'block';document.getElementById('a{0}').style.display = 'none'", index)),
                new XAttribute("class", "expandCode"),
                ". . ."),
            PreTag(lines, 2, lines.Length - 4,
                new XAttribute("id", "log" + index),
                new XAttribute("style", "display:none;")),
            PreTag(lines, lines.Length - 2, 2)
        };
    }
开发者ID:RuneAndersen,项目名称:C1-CMS,代码行数:33,代码来源:log.aspx.cs


示例7: LogEntrySerialiseDeserialise

        public void LogEntrySerialiseDeserialise()
        {
            var originalLogEntry = new LogEntry()
            {
                Timestamp = DateTime.UtcNow,
                Status = LogStatus.Fatal,
                GroupKey = Guid.NewGuid(),
                TargetKey = Guid.NewGuid(),
                InstanceKey = Guid.NewGuid(),
                LogContent = "Test Log Entry",
            };

            LogEntry secondLogEntry;
            using (var stream = originalLogEntry.Serialise())
            {
                secondLogEntry = new LogEntry(stream);
            }

            Assert.AreEqual(originalLogEntry.Timestamp, secondLogEntry.Timestamp);
            Assert.AreEqual(originalLogEntry.Status, secondLogEntry.Status);
            Assert.AreEqual(originalLogEntry.GroupKey, secondLogEntry.GroupKey);
            Assert.AreEqual(originalLogEntry.TargetKey, secondLogEntry.TargetKey);
            Assert.AreEqual(originalLogEntry.InstanceKey, secondLogEntry.InstanceKey);
            Assert.AreEqual(originalLogEntry.LogContent, secondLogEntry.LogContent);
        }
开发者ID:danielrbradley,项目名称:Plywood,代码行数:25,代码来源:LogEntryTests.cs


示例8: CreateRandomLogEntries

	void CreateRandomLogEntries(int howMany)
	{
		for (int i = 0; i < howMany; i++)
		{
			float date = Random.Range(i* RTSDirector.instance.gameDay, ((i+1))*RTSDirector.instance.gameDay)/ howMany;

			LogEntry scratchLogEntry = new LogEntry();

			scratchLogEntry.date = date;
			//scratchLogEntry.location = whatever;
			scratchLogEntry.who = scratchLogEntry.whoArray[Random.Range(0, scratchLogEntry.whoArray.Length)] ;
			scratchLogEntry.didWhat = scratchLogEntry.didWhatArray[Random.Range(0, scratchLogEntry.didWhatArray.Length)];

			scratchLogEntry.whatSubject = scratchLogEntry.whatSubjectArray[Random.Range(0, scratchLogEntry.whatSubjectArray.Length)];
			if(scratchLogEntry.whatSubject == "floating debris")
				scratchLogEntry.doingWhat = "";
			else
				scratchLogEntry.doingWhat = scratchLogEntry.doingWhatArray[Random.Range(0, scratchLogEntry.doingWhatArray.Length)];

			scratchLogEntry.where = scratchLogEntry.whereArray[Random.Range(0, scratchLogEntry.whereArray.Length)];

			scratchLogEntry.message = "Day " + scratchLogEntry.date.ToString("n1") + ": "+
				scratchLogEntry.who+ " "+
				scratchLogEntry.didWhat + " "+ 
				scratchLogEntry.whatSubject	+ " "+
				scratchLogEntry.doingWhat + " "+
				scratchLogEntry.where + ".\n\n";

			logEntryList.Add(scratchLogEntry);
		}
	}
开发者ID:JtheSpaceC,项目名称:Space-Game,代码行数:31,代码来源:ActivityLog.cs


示例9: SendMessageCore

        /// <summary>
        /// Append the log entry to the configured text file.
        /// </summary>
        /// <param name="logEntry"><see cref="LogEntry"></see> to be appended to logging file</param>
        protected override void SendMessageCore(LogEntry logEntry)
        {
            if (ValidateParameters(logEntry))
            {
                try
                {
                   webservice.Logging ws = new webservice.Logging();
                   ws.Url = this.wsSinkData.Url;

                   webservice.WSLogEntry wsLogEntry = new webservice.WSLogEntry();
                   wsLogEntry.Message = logEntry.Message;
                   wsLogEntry.Priority = logEntry.Priority;
                   wsLogEntry.Category = logEntry.Category;
                   wsLogEntry.EventId = logEntry.EventId;
                   wsLogEntry.Severity = (webservice.Severity)Enum.Parse(typeof(webservice.Severity), logEntry.Severity.ToString());
                   wsLogEntry.Title = logEntry.Title;
                   wsLogEntry.ExtendedProperties = WSLogEntry.ToJaggedArray((Hashtable)logEntry.ExtendedProperties);

                   ws.Log(wsLogEntry);

                }
                catch (Exception e)
                {
                    logEntry.AddErrorMessage(SR.SinkFailure(e.ToString()));
                    throw;
                }
                catch
                {
                    logEntry.AddErrorMessage(SR.SinkFailure(SR.UnknownError));
                }
            }
        }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:36,代码来源:WSSink.cs


示例10: FormatToken

        /// <summary>
        /// Iterates through each entry in the dictionary and display the key and/or value.
        /// </summary>
        /// <param name="tokenTemplate">Template to repeat for each key/value pair.</param>
        /// <param name="log">Log entry containing the extended properties dictionary.</param>
        /// <returns>Repeated template for each key/value pair.</returns>
        public override string FormatToken(string tokenTemplate, LogEntry log)
        {
            StringBuilder dictionaryBuilder = new StringBuilder();
            foreach (KeyValuePair<string, object> entry in log.ExtendedProperties)
            {
                StringBuilder singlePair = new StringBuilder(tokenTemplate);
                string keyName = "";
                if (entry.Key != null)
                {
                    keyName = entry.Key.ToString();
                }
                singlePair.Replace(DictionaryKeyToken, keyName);

                string keyValue = "";
                if (entry.Value != null)
                {
                    keyValue = entry.Value.ToString();
                }
                singlePair.Replace(DictionaryValueToken, keyValue);

                dictionaryBuilder.Append(singlePair.ToString());
            }

            return dictionaryBuilder.ToString();
        }
开发者ID:wuyingyou,项目名称:uniframework,代码行数:31,代码来源:DictionaryToken.cs


示例11: LogWrite

        /// <summary>
        /// Writes trace input to <see cref="Log.Write" />.
        /// </summary>
        /// <remarks>This is the method into which all TraceListener Write methods call.</remarks>
        private static void LogWrite(object o, string category = null)
        {
            if (RecursionCounter.Depth > 0)
            {
                return;
            }
            using (RecursionCounter.Enter())
            {
                LogEntry logEntry;

                var d = o as Delegate;
                if (d != null)
                {
                    logEntry = new LogEntry(d.DynamicInvoke(), d.GetAnonymousMethodInfo());
                }
                else if (o is LogEntry)
                {
                    logEntry = (LogEntry) o;
                }
                else
                {
                    logEntry = new LogEntry(o);
                }

                logEntry.Category = category;
                Log.Write(logEntry);
            }
        }
开发者ID:wli3,项目名称:Its.Log,代码行数:32,代码来源:TraceListener.cs


示例12: GetColorByEntry

 protected ConsoleColor GetColorByEntry(LogEntry logEntry)
 {
     if(!this.UseColor)
         return Console.ForegroundColor;
     switch(logEntry.LogType) {
         case LogEntry.LogTypes.Debug:
             return ConsoleColor.DarkGray;
             break;
         case LogEntry.LogTypes.Error:
             return XConsole.XConsole.ErrorColor;
             break;
         case LogEntry.LogTypes.Exception:
                                 return XConsole.XConsole.ErrorColor;
             break;
         case LogEntry.LogTypes.Fatal:
                                 return XConsole.XConsole.ErrorColor;
             break;
         case LogEntry.LogTypes.Success:
             return XConsole.XConsole.SuccessColor;
             break;
         case LogEntry.LogTypes.Warn:
             return XConsole.XConsole.WarningColor;
             break;
     }
     return Console.ForegroundColor;
 }
开发者ID:KillerGoldFisch,项目名称:GCharp,代码行数:26,代码来源:ConsoleLogger.cs


示例13: FormatLogEntry

        /// <summary>
        /// Format a log entry as it should be written to the file
        /// </summary>
        /// <param name="entry">Entry to format</param>
        /// <returns>
        /// Formatted entry
        /// </returns>
        protected override string FormatLogEntry(LogEntry entry)
        {
            string result;
            var ex = entry.Exception; // to satisfy code contracts
            if (ex != null)
            {
                result= string.Format("{0} {1} {2} {3} {4} {5}\r\n{6}\r\n",
                                     entry.CreatedAt.ToString(Configuration.DateTimeFormat),
                                     entry.LogLevel.ToString().PadRight(8, ' '),
                                     entry.ThreadId.ToString("000"),
                                     FormatUserName(entry.UserName, 16).PadRight(16),
                                     FormatStackTrace(entry.StackFrames, 40).PadRight(40),
                                     FormatMessage(entry.Message),
                                     FormatException(ex, 1)
                    );
            }
            else
            {
                result= string.Format("{0} {1} {2} {3} {4} {5}\r\n",
                              entry.CreatedAt.ToString(Configuration.DateTimeFormat),
                              entry.LogLevel.ToString().PadRight(8, ' '),
                              entry.ThreadId.ToString("000"),
                              FormatUserName(entry.UserName, 16).PadRight(16),
                              FormatStackTrace(entry.StackFrames, 40).PadRight(40),
                              FormatMessage(entry.Message)
                    );
            }

            // do make Code Contracts shut up.
            return string.IsNullOrEmpty(result) ? "Invalid entry" : result;
        }
开发者ID:jmptrader,项目名称:griffin,代码行数:38,代码来源:PaddedFileTarget.cs


示例14: ApplyResolvesClientIpAddress

        public void ApplyResolvesClientIpAddress()
        {
            var lookup = new Mock<IIpLookupService>();
            var target = new GeoLookupTransformation(lookup.Object);

            string cIpAddress = "myClientIp";

            string sIpAddress = "myServerIp";

            var entry = new LogEntry
            {
                cIp = cIpAddress,
                sIp = sIpAddress,
            };

            lookup.Setup(l => l.GetCountry(It.IsAny<string>())).Returns(new Country(TestCountryCode, TestCountryName));

            target.Apply(entry);

            Assert.Equal(TestCountryName, entry.CountryName);
            Assert.Equal(TestCountryCode, entry.CountryCode);

            lookup.Verify(l => l.GetCountry(sIpAddress), Times.Never());
            lookup.Verify(l => l.GetCountry(cIpAddress), Times.AtLeastOnce());
        }
开发者ID:peschuster,项目名称:LogImporter,代码行数:25,代码来源:GeoLookupTransformationTest.cs


示例15: SendLogEntry

        void SendLogEntry(WmiTraceListener listener,
                          LogEntry logEntry)
        {
            ManagementScope scope = new ManagementScope(@"\\." + wmiPath);
            scope.Options.EnablePrivileges = true;

            StringBuilder sb = new StringBuilder("SELECT * FROM ");
            sb.Append("LogEntryV20");
            string query = sb.ToString();
            EventQuery eq = new EventQuery(query);

            using (ManagementEventWatcher watcher = new ManagementEventWatcher(scope, eq))
            {
                watcher.EventArrived += new EventArrivedEventHandler(watcher_EventArrived);
                watcher.Start();

                LogSource source = new LogSource("notfromconfig", SourceLevels.All);
                source.Listeners.Add(listener);
                source.TraceData(TraceEventType.Error, 1, logEntry);

                BlockUntilWMIEventArrives();

                watcher.Stop();
            }
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:25,代码来源:WMIListenerFixture.cs


示例16: FormatLogEntry

        private SyndicationItem FormatLogEntry(LogEntry entry, string repo)
        {
            var markdownParser = new Markdown(true);
            var item = new SyndicationItem();

            item.Id = entry.CommitHash;
            item.Title = new TextSyndicationContent(entry.Subject);
            item.Content = SyndicationContent.CreateHtmlContent(markdownParser.Transform(entry.Subject + "\n\n" + entry.Body));
            item.LastUpdatedTime = entry.AuthorDate;
            item.PublishDate = entry.CommitterDate;

            item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(Url.Action("ViewCommit", "Browse", new { repo, @object = entry.CommitHash }), UriKind.Relative)));

            item.Categories.Add(new SyndicationCategory("commit"));
            if (entry.Parents.Count > 1)
            {
                item.Categories.Add(new SyndicationCategory("merge"));
            }

            item.Authors.Add(new SyndicationPerson(entry.AuthorEmail, entry.Author, null));
            if (entry.Author != entry.Committer || entry.AuthorEmail != entry.CommitterEmail)
            {
                item.Contributors.Add(new SyndicationPerson(entry.CommitterEmail, entry.Committer, null));
            }

            return item;
        }
开发者ID:JasSra,项目名称:WebGitNet,代码行数:27,代码来源:SyndicationController.cs


示例17: Write

		public void Write(LogEntry entry)
		{
			using (OleDbConnection conn = new OleDbConnection(connStr))
			{
				using (OleDbCommand cmd = conn.CreateCommand()) 
				{
					cmd.CommandText = @"
						INSERT INTO [Request]
						(Date, Method, URL, Referral, ASPNETSessionID, UserHost, UserAddress, UserAgent)
						VALUES
						(@Date, @Method, @URL, @Referral, @ASPNETSessionID, @UserHost, @UserAddress, @UserAgent)
					";

					cmd.Parameters.Add("@Date", entry.Date);
					cmd.Parameters.Add("@Method", entry.Method);
					cmd.Parameters.Add("@URL", Convert.ToString(entry.Url));
					cmd.Parameters.Add("@Referral", Convert.ToString(entry.Referral));
					cmd.Parameters.Add("@ASPNETSessionID", entry.ASPNETSessionID);
					cmd.Parameters.Add("@UserHost", entry.UserHost);
					cmd.Parameters.Add("@UserAddress", entry.UserAddress);
					cmd.Parameters.Add("@UserAgent", entry.UserAgent);

					conn.Open();
					cmd.ExecuteNonQuery();
				}
			}
		}
开发者ID:elementar,项目名称:Suprifattus.Util,代码行数:27,代码来源:OleDbOutputFilter.cs


示例18: OnLogged

        private void OnLogged(string message)
        {
            var logEntry = new LogEntry();
            logEntry.Message = message;

            LogEntries.Add(logEntry);
        }
开发者ID:rexwhitten,项目名称:NUnitBenchmarker,代码行数:7,代码来源:LogEntriesViewModel.cs


示例19: Enqueue

        public void Enqueue(LogEntry entry)
        {
            if (Filters.Any(f => !f.CanLog(entry)))
                return;

            Entries.Add(entry);
        }
开发者ID:jmptrader,项目名称:Griffin.Logging,代码行数:7,代码来源:TestTarget.cs


示例20: Log

            public override void Log(LogEntry logEntry)
            {
                lock (_bufferLock)
                {
                    _bufferedEntries.Add(logEntry);
                }

                lock (_timerLock)
                {

                    if (_maxTimer == null)
                    {
                        _minTimer = new Timer(MinimumWaitTime.TotalMilliseconds) { AutoReset = false };
                        _maxTimer = new Timer(MaximumWaitTime.TotalMilliseconds) { AutoReset = false };
                        _minTimer.Elapsed += UnspoolBuffer;
                        _maxTimer.Elapsed += UnspoolBuffer;
                        _minTimer.Start();
                        _maxTimer.Start();
                    }
                    else
                    {
                        if (_minTimer != null)
                        {
                            _minTimer.Close();
                        }
                        _minTimer = new Timer(MinimumWaitTime.TotalMilliseconds) { AutoReset = false };
                        _minTimer.Elapsed += UnspoolBuffer;
                        _minTimer.Start();
                    }
                }
            }
开发者ID:dineshkummarc,项目名称:Log5,代码行数:31,代码来源:LogBuffer.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# LogEntryType类代码示例发布时间:2022-05-24
下一篇:
C# LogDelegate类代码示例发布时间: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