/// <summary> /// Creates an event listener that logs using a <see cref="SeqSink" />. /// </summary> /// <param name="serverUrl">The base URL of the Seq server that log events will be written to.</param> /// <param name="apiKey">A Seq <i>API key</i> that authenticates the client to the Seq server.</param> /// <param name="bufferingInterval">The buffering interval between each batch publishing. Default value is <see cref="Buffering.DefaultBufferingInterval" />.</param> /// <param name="listenerDisposeTimeout">Time limit for flushing the entries after an <see cref="SeqSink.OnCompleted" /> call is received and before disposing the sink.</param> /// <param name="bufferingCount">Number of entries that will trigger batch publishing. Default is <see cref="Buffering.DefaultBufferingCount" /></param> /// <param name="maxBufferSize">The maximum number of entries that can be buffered 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="SeqSink" /> to log events. /// </returns> public static EventListener CreateListener( string serverUrl, string apiKey = null, TimeSpan? bufferingInterval = null, TimeSpan? listenerDisposeTimeout = null, int bufferingCount = Buffering.DefaultBufferingCount, int maxBufferSize = Buffering.DefaultMaxBufferSize) { var listener = new ObservableEventListener(); listener.LogToSeq(serverUrl, apiKey, bufferingInterval, listenerDisposeTimeout, bufferingCount, maxBufferSize); return listener; }
/// <summary> /// Creates an event listener that logs using a <see cref="SeqSink" />. /// </summary> /// <param name="serverUrl">The base URL of the Seq server that log events will be written to.</param> /// <param name="apiKey">A Seq <i>API key</i> that authenticates the client to the Seq server.</param> /// <param name="bufferingInterval">The buffering interval between each batch publishing. Default value is <see cref="Buffering.DefaultBufferingInterval" />.</param> /// <param name="listenerDisposeTimeout">Time limit for flushing the entries after an <see cref="SeqSink.OnCompleted" /> call is received and before disposing the sink.</param> /// <param name="bufferingCount">Number of entries that will trigger batch publishing. Default is <see cref="Buffering.DefaultBufferingCount" /></param> /// <param name="maxBufferSize">The maximum number of entries that can be buffered 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="SeqSink" /> to log events. /// </returns> public static EventListener CreateListener( string serverUrl, string apiKey = null, TimeSpan?bufferingInterval = null, TimeSpan?listenerDisposeTimeout = null, int bufferingCount = Buffering.DefaultBufferingCount, int maxBufferSize = Buffering.DefaultMaxBufferSize) { var listener = new ObservableEventListener(); listener.LogToSeq(serverUrl, apiKey, bufferingInterval, listenerDisposeTimeout, bufferingCount, maxBufferSize); return(listener); }
static void Main() { using (var listener = new ObservableEventListener()) { listener.EnableEvents(SampleEventSource.Log, EventLevel.LogAlways, SampleEventSource.Keywords.SampleApp); listener.LogToConsole(); listener.LogToSeq("http://my-seq"); SampleEventSource.Log.Greeting(Environment.UserName); } Console.WriteLine("Done"); Console.ReadKey(true); }