本文整理汇总了C#中ObservableEventListener.LogToElasticsearch方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableEventListener.LogToElasticsearch方法的具体用法?C# ObservableEventListener.LogToElasticsearch怎么用?C# ObservableEventListener.LogToElasticsearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableEventListener
的用法示例。
在下文中一共展示了ObservableEventListener.LogToElasticsearch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateListener
/// <summary>
/// Creates an event listener that logs using a <see cref="ElasticsearchSink" />.
/// </summary>
/// <param name="instanceName">The name of the instance originating the entries.</param>
/// <param name="connectionString">The endpoint address for the Elasticsearch Service.</param>
/// <param name="index">Index name prefix formatted as index-{0:yyyy.MM.DD}</param>
/// <param name="type">The Elasticsearch entry type</param>
/// <param name="flattenPayload">Flatten the payload collection when serializing event entries</param>
/// <param name="bufferingInterval">The buffering interval between each batch publishing.</param>
/// <param name="listenerDisposeTimeout">Defines a timeout interval for the flush operation when the listener is disposed.</param>
/// <param name="maxBufferSize">The maximum number of entries that can be buffered while it's sending to Elasticsearch 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. 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>
/// <returns>
/// An event listener that uses <see cref="ElasticsearchSink" /> to log events.
/// </returns>
public static EventListener CreateListener(string instanceName, string connectionString, string index, string type, bool flattenPayload = true,
TimeSpan? bufferingInterval = null, TimeSpan? listenerDisposeTimeout = null, int maxBufferSize = Buffering.DefaultMaxBufferSize)
{
var listener = new ObservableEventListener();
listener.LogToElasticsearch(instanceName, connectionString, index, type, flattenPayload, bufferingInterval,
listenerDisposeTimeout, maxBufferSize);
return listener;
}
示例2: Application_Start
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
var listener = new ObservableEventListener();
listener.EnableEvents(TestEvents.Log, EventLevel.LogAlways, Keywords.All);
listener.LogToConsole();
listener.LogToElasticsearch("SLABEL", "http://localhost:9200", "myindex", "mytype", bufferingCount: 1);
TestEvents.Log.Critical("Hello world In-Process Critical");
TestEvents.Log.Error("Hello world In-Process Error");
TestEvents.Log.Informational("Hello world In-Process Informational");
}