Пример #1
0
 /// <summary>
 /// Configures Rebus to use Serilog for all of its internal logging, using Serilog's global <see cref="Log.Logger"/> as base logger
 /// </summary>
 public static void Serilog(this RebusLoggingConfigurer configurer)
 {
     if (configurer == null)
     {
         throw new ArgumentNullException(nameof(configurer));
     }
     configurer.Use(new SerilogLoggerFactory(Log.Logger));
 }
 /// <summary>
 /// Configures Rebus to use Microsoft Extensions Logging for all of its internal logging, used the given <paramref name="loggerFactory"/> to create
 /// typed loggers to use
 /// </summary>
 public static void MicrosoftExtensionsLogging(this RebusLoggingConfigurer configurer, ILoggerFactory loggerFactory)
 {
     if (configurer == null)
     {
         throw new ArgumentNullException(nameof(configurer));
     }
     if (loggerFactory == null)
     {
         throw new ArgumentNullException(nameof(loggerFactory));
     }
     configurer.Use(new MicrosoftExtensionsLoggingLoggerFactory(loggerFactory));
 }
Пример #3
0
        static void TryConfigurePipelineStep(RebusLoggingConfigurer configurer)
        {
            var injectionistField = configurer.GetType()
                                    .GetField("_injectionist", BindingFlags.Instance | BindingFlags.NonPublic);

            var injectionist = injectionistField?.GetValue(configurer) as Injectionist;

            injectionist?.Decorate <IPipeline>(c =>
            {
                var pipeline = c.Get <IPipeline>();

                return(new PipelineStepConcatenator(pipeline)
                       .OnReceive(new Log4NetContextStep(), PipelineAbsolutePosition.Front));
            });
        }
Пример #4
0
        /// <summary>
        /// Configures Rebus to use Log4Net for all of its internal logging, getting its loggers by calling logger <see cref="LogManager.GetLogger(Type)"/>
        /// </summary>
        public static void Log4Net(this RebusLoggingConfigurer configurer)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException(nameof(configurer));
            }

            configurer.Use(new Log4NetLoggerFactory());

            try
            {
                TryConfigurePipelineStep(configurer);
            }
            catch { }
        }