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


C# TraceSource.TraceData方法代码示例

本文整理汇总了C#中System.Diagnostics.TraceSource.TraceData方法的典型用法代码示例。如果您正苦于以下问题:C# TraceSource.TraceData方法的具体用法?C# TraceSource.TraceData怎么用?C# TraceSource.TraceData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Diagnostics.TraceSource的用法示例。


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

示例1: submitCodeBehindButton_Click

    protected void submitCodeBehindButton_Click(object sender, EventArgs e)
    {
        System.Diagnostics.TraceSource source =
            new System.Diagnostics.TraceSource(sourceTextBox.Text);

        source.TraceData(System.Diagnostics.TraceEventType.Error, 100, "Test from the code behind");
    }
开发者ID:alienwaredream,项目名称:toolsdotnet,代码行数:7,代码来源:LoggingPage.aspx.cs

示例2: TestLogException

 public void TestLogException()
 {
     try
     {
         throw new Exception("First inner exception");
     }
     catch (Exception firstInnerException)
     {
         try
         {
             throw new Exception("Second inner exception", firstInnerException);
         }
         catch (Exception secondInnerException)
         {
             try
             {
                 throw new Exception("Outermost exception.", secondInnerException);
             }
             catch (Exception ex)
             {
                 ex.Data.Add("UnitTest", "SqlTraceListenerTest");
                 var traceSource = new TraceSource("TestTraceSource");
                 traceSource.TraceData(TraceEventType.Error, 1979, ex);
             }
         }
     }
 }
开发者ID:mike-dempster,项目名称:Pelorus,代码行数:27,代码来源:SqlTraceListenerTest.cs

示例3: Application_Start

 protected void Application_Start(Object sender, EventArgs e)
 {
     TaskScheduler.UnobservedTaskException +=
         ( object sender2, UnobservedTaskExceptionEventArgs args) =>
         {
             var trace = new TraceSource("UnhandledExceptionTrace Tasks");
             trace.TraceData(TraceEventType.Error, 1, args.Exception);
             args.SetObserved();
         };
 }
开发者ID:nehawadhwa,项目名称:ccweb,代码行数:10,代码来源:Global.asax.cs

示例4: Main

        public static void Main(string[] args)
        {
            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);

            traceSource.TraceInformation("Tracing application...");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1, new object[] { "a", "b", "c" });

            traceSource.Flush();
            traceSource.Close();
        }
开发者ID:nissbran,项目名称:Training-Certifications,代码行数:11,代码来源:Program.cs

示例5: TestTraceSourceLogging

        public void TestTraceSourceLogging()
        {
            TraceSource source = new TraceSource("TestOfIoCXmlRollingWriter");

            for (int i = 0; i < 100000; i++)
            {
                source.TraceData(TraceEventType.Information, i, "test of test data");
                source.Flush();
            }
            source.Flush();
        }
开发者ID:alienwaredream,项目名称:toolsdotnet,代码行数:11,代码来源:XmlWriterRollingTraceSourceTest.cs

示例6: HowToUseTheTraceSourceClass

        public static void HowToUseTheTraceSourceClass()
        {
            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);

            traceSource.TraceInformation("Tracing app");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1, new object[] { "a", "b", "c" });

            traceSource.Flush();
            traceSource.Close();
        }
开发者ID:Chaek,项目名称:MCSD,代码行数:11,代码来源:TraceSourceExample.cs

示例7: FormatterListenerAsString

        public void FormatterListenerAsString()
        {
            FormattedDatabaseTraceListener listener = new FormattedDatabaseTraceListener(new SqlDatabase(connectionString), "WriteLog", "AddCategory", new TextFormatter("TEST{newline}TEST"));

            // need to go through the source to get a TraceEventCache
            TraceSource source = new TraceSource("notfromconfig", SourceLevels.All);
            source.Listeners.Add(listener);
            source.TraceData(TraceEventType.Error, 0, "test message");

            string messageContents = GetLastLogMessage("LoggingDb");

            Assert.AreEqual("test message", messageContents);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:13,代码来源:FormattedDatabaseTraceListenerFixture.cs

示例8: TraceData

 internal static void TraceData(TraceSource source, TraceEventType eventType,
     Enum eventId, object data)
 {
     try
     {
         source.TraceData(eventType, Convert.ToInt32(eventId), data);
     }
     catch (Exception ex)
     {
         Console.Write(ex.ToString()); // will get into standard output then
         // this is the lowest fallback possible (SD)
     }
 }
开发者ID:alienwaredream,项目名称:toolsdotnet,代码行数:13,代码来源:Log.cs

示例9: Main

        static void Main(string[] args)
        {
            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);

            traceSource.TraceInformation("Tracing application.");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1, new object[] { "a", "b", "c" });

            traceSource.Flush();
            traceSource.Close();

            Console.WriteLine("Press a key to exit");
            Console.ReadKey();
        }
开发者ID:jbijoux,项目名称:Exam70_483,代码行数:14,代码来源:Program.cs

示例10: HowToUseTheTraceListenerClass

        public static void HowToUseTheTraceListenerClass()
        {
            Stream outputFile = File.Create("traceFile.txt");
            TextWriterTraceListener textListener = new TextWriterTraceListener(outputFile);

            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);

            traceSource.Listeners.Clear();
            traceSource.Listeners.Add(textListener);

            traceSource.TraceInformation("Tracing app");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1, new object[] { "a", "b", "c" });

            traceSource.Flush();
            traceSource.Close();
        }
开发者ID:Chaek,项目名称:MCSD,代码行数:17,代码来源:TraceSourceListenerExample.cs

示例11: Main

        static void Main(string[] args)
        {
            Debug.WriteLine("Starting application");
            Debug.Indent();
            int i = 1 + 2;
            Debug.Assert(i == 3);
            Debug.WriteLineIf(i > 0, "i is greater than 0");

            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);
            traceSource.TraceInformation("Tracing application..");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1,
            new object[] { "a", "b", "c" });
            traceSource.Flush();
            traceSource.Close();

            DoTrace();

            Console.ReadLine();
        }
开发者ID:ErhanGDC,项目名称:MyWorks,代码行数:20,代码来源:Program.cs

示例12: ExecuteDbDataReader

        protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
        {
            var allParameters = GetParams();
            _columnMap = allParameters.Where(a => a.Name.StartsWith(ColumnMap.ColumnRename, StringComparison.OrdinalIgnoreCase));

            var parameters = allParameters.Except(_columnMap, new ColumnMapComparer());

            foreach (var parameter in parameters)
            {
                // dapper 1.7+ rips off the @, this allows for either @ or no prefix to be found and replaced
                var name = parameter.Name.StartsWith(ColumnMap.Parameter, StringComparison.OrdinalIgnoreCase) ? parameter.Name : ColumnMap.Parameter + parameter.Name;
                _command.CommandText = _command.CommandText.Replace(name, parameter.Value.ToString());

            }

            var trace = new System.Diagnostics.TraceSource("mdx");
            trace.TraceData(System.Diagnostics.TraceEventType.Information, 0, _command.CommandText);

            var results = PopulateFromXml(_command.ExecuteXmlReader());

            return behavior == CommandBehavior.CloseConnection ? new MdxDataReader(results, _connection) : new MdxDataReader(results);
        }
开发者ID:DynamicTyped,项目名称:MdxClient,代码行数:22,代码来源:MdxCommand.cs

示例13: TraceData

 internal static void TraceData(TraceSource source, TraceEventType eventType,
     Enum eventId, object data)
 {
     source.TraceData(eventType, Convert.ToInt32(eventId), data);
 }
开发者ID:alienwaredream,项目名称:toolsdotnet,代码行数:5,代码来源:Log.cs

示例14: TraceDataTests

        public void TraceDataTests()
        {
            LogManager.Configuration = CreateConfigurationFromString(@"
                <nlog>
                    <targets><target name='debug' type='Debug' layout='${logger} ${level} ${message} ${event-context:EventID}' /></targets>
                    <rules>
                        <logger name='*' minlevel='Trace' writeTo='debug' />
                    </rules>
                </nlog>");

            TraceSource ts = new TraceSource("MySource1", SourceLevels.All);
            ts.Listeners.Add(new NLogTraceListener { Name = "Logger1", DefaultLogLevel = LogLevel.Trace });

            ts.TraceData(TraceEventType.Critical, 123, 42);
            AssertDebugLastMessage("debug", "MySource1 Fatal 42 123");

            ts.TraceData(TraceEventType.Critical, 145, 42, 3.14, "foo");
            AssertDebugLastMessage("debug", "MySource1 Fatal 42, 3.14, foo 145");
        }
开发者ID:rameshr,项目名称:NLog,代码行数:19,代码来源:NLogTraceListenerTests.cs

示例15: LogToEmailUsingDirectObjectOnlyResultsInOneMessage

        public void LogToEmailUsingDirectObjectOnlyResultsInOneMessage()
        {
            MockEmailTraceListener listener = new MockEmailTraceListener("[email protected];[email protected]", "[email protected]",
                                        "EntLib-Logging ->", "has occurred", "smtphost");

            TraceSource source = new TraceSource("unnamed", SourceLevels.All);
            source.Listeners.Add(listener);

            int numMessages = listener.MessagesSent;

            source.TraceData(TraceEventType.Error, 1, new TestCustomObject());
            source.Close();

            int newNumMessages = listener.MessagesSent;

            Assert.AreEqual(numMessages, newNumMessages - 1);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:17,代码来源:EmailTraceListenerFixture.cs


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