Пример #1
0
        /// <summary>
        /// Creates an event listener that logs using a <see cref="ApplicationInsightsSink" />.
        /// </summary>
        /// <param name="TelemetryInitializer">The (optional) Application Insights telemetry initializers.</param>
        /// <returns>
        /// An event listener that uses <see cref="ApplicationInsightsSink" /> to log events.
        /// </returns>
        public static EventListener CreateListener(params ITelemetryInitializer[] telemetryInitializers)
        {
            var listener = new ObservableEventListener();

            listener.LogToApplicationInsights(telemetryInitializers);
            return(listener);
        }
Пример #2
0
        /// <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 SQL Database 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);
        }
Пример #3
0
        /// <summary>
        /// Creates an event listener that logs using a <see cref="FlatFileSink"/>.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="formatter">The formatter.</param>
        /// <param name="isAsync">Specifies if the writing should be done asynchronously, or synchronously with a blocking call.</param>
        /// <returns>An event listener that uses <see cref="FlatFileSink"/> to log events.</returns>
        public static EventListener CreateListener(string fileName = null, IEventTextFormatter formatter = null, bool isAsync = false)
        {
            var listener = new ObservableEventListener();

            listener.LogToFlatFile(fileName, formatter, isAsync);
            return(listener);
        }
Пример #4
0
        /// <summary>
        /// Creates an event listener that logs using a <see cref="ConsoleSink"/>.
        /// </summary>
        /// <param name="formatter">The formatter.</param>
        /// <param name="colorMapper">The color mapper instance.</param>
        /// <returns>An event listener that uses <see cref="ConsoleSink"/> to display events.</returns>
        public static EventListener CreateListener(IEventTextFormatter formatter = null, IConsoleColorMapper colorMapper = null)
        {
            var listener = new ObservableEventListener();

            listener.LogToConsole(formatter, colorMapper);
            return(listener);
        }
        /// <summary>
        /// Creates an event listener that logs using a <see cref="ApplicationInsightsSink" />.
        /// </summary>
        /// <param name="InstrumentationKey">The ID that determines the application component under which your data appears in Application Insights.</param>
        /// <param name="contextInitializers">The (optional) Application Insights context initializers.</param>
        /// <returns>
        /// An event listener that uses <see cref="ApplicationInsightsSink" /> to log events.
        /// </returns>
        public static EventListener CreateListener(String InstrumentationKey, params IContextInitializer[] contextInitializers)
        {
            var listener = new ObservableEventListener();

            listener.LogToApplicationInsights(InstrumentationKey, contextInitializers);
            return(listener);
        }
        /// <summary>
        /// Creates an event listener that logs using a <see cref="WindowsAzureTableSink" />.
        /// </summary>
        /// <param name="instanceName">The name of the instance originating the entries.</param>
        /// <param name="connectionString">The connection string for the storage account.</param>
        /// <param name="tableAddress">Either the name of the table, or the absolute URI to the table.</param>
        /// <param name="bufferingInterval">The buffering interval between each batch publishing.</param>
        /// <param name="sortKeysAscending">The value indicating whether to sort the row keys in ascending order.</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 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. 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="WindowsAzureTableSink" /> to log events.
        /// </returns>
        public static EventListener CreateListener(string instanceName, string connectionString, string tableAddress = DefaultTableName, TimeSpan?bufferingInterval = null, bool sortKeysAscending = false, TimeSpan?listenerDisposeTimeout = null, int maxBufferSize = Buffering.DefaultMaxBufferSize)
        {
            var listener = new ObservableEventListener();

            listener.LogToWindowsAzureTable(instanceName, connectionString, tableAddress, bufferingInterval, sortKeysAscending, listenerDisposeTimeout, maxBufferSize);
            return(listener);
        }
Пример #7
0
        /// <summary>
        /// Creates an event listener that logs using a <see cref="RollingFlatFileSink"/>.
        /// </summary>
        /// <param name="fileName">The filename where the entries will be logged.</param>
        /// <param name="rollSizeKB">The maximum file size (KB) before rolling.</param>
        /// <param name="timestampPattern">The date format that will be appended to the new roll file.</param>
        /// <param name="rollFileExistsBehavior">Expected behavior that will be used when the roll file has to be created.</param>
        /// <param name="rollInterval">The time interval that makes the file to be rolled.</param>
        /// <param name="formatter">The formatter.</param>
        /// <param name="maxArchivedFiles">The maximum number of archived files to keep.</param>
        /// <param name="isAsync">Specifies if the writing should be done asynchronously, or synchronously with a blocking call.</param>
        /// <returns>An event listener that uses <see cref="RollingFlatFileSink"/> to log events.</returns>
        public static EventListener CreateListener(string fileName, int rollSizeKB, string timestampPattern, RollFileExistsBehavior rollFileExistsBehavior, RollInterval rollInterval, IEventTextFormatter formatter = null, int maxArchivedFiles = 0, bool isAsync = false)
        {
            var listener = new ObservableEventListener();

            listener.LogToRollingFlatFile(fileName, rollSizeKB, timestampPattern, rollFileExistsBehavior, rollInterval, formatter, maxArchivedFiles, isAsync);
            return(listener);
        }
Пример #8
0
        /// <summary>
        /// Creates an event listener that logs using a <see cref="ApplicationInsightsSink" />.
        /// </summary>
        /// <param name="InstrumentationKey">The ID that determines the application component under which your data appears in Application Insights.</param>
        /// <param name="contextInitializers">The (optional) Application Insights context initializers.</param>
        /// <returns>
        /// An event listener that uses <see cref="ApplicationInsightsSink" /> to log events.
        /// </returns>
        public static EventListener CreateListener(Form1 form1)
        {
            var listener = new ObservableEventListener();

            listener.LogToWindowsForm(form1);
            return(listener);
        }
Пример #9
0
        /// <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);
        }