Ejemplo n.º 1
0
        /// <summary>
        /// Adds an ILogger as a target to logging the performance counts
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="logger"></param>
        /// <returns></returns>
        public static IPerformanceLoggerBuilder AddLogger(this IPerformanceLoggerBuilder builder, ILogger logger)
        {
            // Create target from the logger
            var loggingTarget = new LoggerTarget(logger);

            return(builder.AddTarget(loggingTarget));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a Postgres database as a target for logging the performance of the application.
        /// The table will be created in the database if it does not exist. The default table
        /// name will be perflogs.
        /// </summary>
        public static IPerformanceLoggerBuilder AddPostgres(
            this IPerformanceLoggerBuilder builder,
            string connectionString,
            string tableName = "perflogs")
        {
            // Create target and its batch writer
            var batchWriter   = new BatchWriter(connectionString, tableName, builder.LoggerFactory.CreateLogger <BatchWriter>());
            var loggingTarget = new PostgresTarget(batchWriter);

            return(builder.AddTarget(loggingTarget));
        }