Пример #1
0
        /// <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 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);
        }
Пример #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="storedProcedureName">The name of the stored procedure that writes to 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, string storedProcedureName = DefaultStoredProcedureName, TimeSpan?bufferingInterval = null, int bufferingCount = Buffering.DefaultBufferingCount, TimeSpan?listenerDisposeTimeout = null, int maxBufferSize = Buffering.DefaultMaxBufferSize)
        {
            var listener = new ObservableEventListener();

            listener.LogToSqlDatabase(instanceName, connectionString, tableName, storedProcedureName, bufferingInterval, bufferingCount, listenerDisposeTimeout, maxBufferSize);
            return(listener);
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
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);
        }