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


C# ObservableEventListener.LogToSqlDatabase方法代码示例

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


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

示例1: CreateListener

 /// <summary>
 /// Subscribes to the listener using a <see cref="SqlDatabaseSink" />.
 /// </summary>
 /// <param name="instanceName">The name of the instance originating the entries.</param>
 /// <param name="connectionString">The connection string.</param>
 /// <param name="tableName">The name of the table.</param>
 /// <param name="bufferingInterval">The buffering interval between each batch publishing.</param>
 /// <param name="bufferingCount">The number of entries that will trigger a batch publishing.</param>
 /// <param name="listenerDisposeTimeout">Defines a timeout interval for the flush operation when the listener is disposed.
 /// This means that if the timeout period elapses, some event entries will be dropped and not sent to the store. Calling <see cref="IDisposable.Dispose"/> on 
 /// the <see cref="EventListener"/> will block until all the entries are flushed or the interval elapses.
 /// If <see langword="null"/> is specified, then the call will block indefinitely until the flush operation finishes.</param>
 /// <param name="maxBufferSize">The maximum number of entries that can be buffered while it's sending to Windows Azure Storage before the sink starts dropping entries.
 /// This means that if the timeout period elapses, some event entries will be dropped and not sent to the store. Normally, calling <see cref="IDisposable.Dispose" /> on
 /// the <see cref="System.Diagnostics.Tracing.EventListener" /> will block until all the entries are flushed or the interval elapses.
 /// If <see langword="null" /> is specified, then the call will block indefinitely until the flush operation finishes.</param>
 /// <returns>An event listener that uses <see cref="SqlDatabaseSink"/> to log events.</returns>
 public static EventListener CreateListener(string instanceName, string connectionString, string tableName = DefaultTableName, TimeSpan? bufferingInterval = null, int bufferingCount = Buffering.DefaultBufferingCount, TimeSpan? listenerDisposeTimeout = null, int maxBufferSize = Buffering.DefaultMaxBufferSize)
 {
     var listener = new ObservableEventListener();
     listener.LogToSqlDatabase(instanceName, connectionString, tableName, bufferingInterval, bufferingCount, listenerDisposeTimeout, maxBufferSize);
     return listener;
 }
开发者ID:Brar,项目名称:entlib,代码行数:23,代码来源:SqlDatabaseLog.cs

示例2: MultipleEventListenersKeywords

    static void MultipleEventListenersKeywords()
    {
      var listener1 = new ObservableEventListener();
      var listener2 = new ObservableEventListener();
      listener1.EnableEvents(MyCompanyEventSource.Log, EventLevel.LogAlways, MyCompanyEventSource.Keywords.Perf | MyCompanyEventSource.Keywords.Diagnostic);
      listener2.EnableEvents(MyCompanyEventSource.Log, EventLevel.LogAlways, Keywords.All);
      // Set up and enable the event listeners -  typically done when the application starts
      listener1.LogToConsole();
      // The SinkSubscription is used later to flush the buffer
      var subscription = listener2.LogToSqlDatabase("Demo Semantic Logging Instance", connectionString);

      // Log some messages
      MyCompanyEventSource.Log.PageStart(23, "http://mysite/demopage");
      MyCompanyEventSource.Log.Startup();
      MyCompanyEventSource.Log.Failure("Couldn't connect to server.");
      Console.WriteLine("Written three log messages.\nUsing a basic console listener and a SQL listener to capture them.");
      Console.WriteLine("Only the messages with the Perf or Diagnostic keywords appears in the console, \nall three appear in the SQL Database:\n");

      // Disable the event listener - typically done when the application terminates
      listener1.DisableEvents(MyCompanyEventSource.Log);
      listener2.DisableEvents(MyCompanyEventSource.Log);

      // Manually flush the buffer so you can see what's in the database
      subscription.Sink.FlushAsync().Wait();
      ShowContentsOfSqlDatabaseTable();

      listener1.Dispose();
      listener2.Dispose();
    }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:29,代码来源:Program.cs


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