Example #1
0
        /// <summary>
        /// Use Serilog as a logging target.
        /// </summary>
        /// <param name="configurationBuilder">The configuration builder.</param>
        /// <param name="configure">The configure action for Serilog.</param>
        /// <returns></returns>
        public static IConfigurationBuilder UseSerilog(this IConfigurationBuilder configurationBuilder, Action <Serilog.LoggerConfiguration> configure)
        {
            var options = new SerilogOptions {
                Configure = configure
            };
            var starter = new SerilogStarter(options);

            configurationBuilder.ExcludeAssemblyFor <SerilogStarter>();
            configurationBuilder.ExcludeAssemblyFor <Serilog.ILogger>();
            configurationBuilder.ExcludeName("Serilog");

            configurationBuilder.Use(starter);

            // register log writer
            configurationBuilder.LogTo(Serilog.Log.Debug);

            return(configurationBuilder);
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SerilogStarter"/> class.
 /// </summary>
 /// <param name="options">The options to use.</param>
 public SerilogStarter(SerilogOptions options)
 {
     _options = options;
 }