/// <summary>
        /// Write to the log an async sink when running the default command (or web server / hosted process).
        /// Write to a sync sink when not running the default command.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="register">The action to register the sink.</param>
        public static ISerilogConventionContext WriteToAsyncConditionally(
            [NotNull] this ISerilogConventionContext context,
            [NotNull] Action <LoggerSinkConfiguration> register
            )
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (register == null)
            {
                throw new ArgumentNullException(nameof(register));
            }

            if (ConfigurationAsyncHelper.IsAsync(context.Configuration))
            {
                context.LoggerConfiguration.WriteTo.Async(register);
            }
            else
            {
                register(context.LoggerConfiguration.WriteTo);
            }

            return(context);
        }
        /// <inheritdoc />
        public void Register([NotNull] ISerilogConventionContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            context.LoggerConfiguration.ReadFrom.Configuration(context.Configuration);
        }
Exemple #3
0
        /// <summary>
        /// Registers the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Register([NotNull] ISerilogConventionContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            context.WriteToAsyncConditionally(Register);
        }
        /// <summary>
        /// Registers the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Register([NotNull] ISerilogConventionContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            context.LoggerConfiguration
            .Enrich.FromLogContext()
            .Enrich.WithDemystifiedStackTraces();
        }
Exemple #5
0
        /// <summary>
        /// Registers the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Register([NotNull] ISerilogConventionContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            context.LoggerConfiguration
            .Enrich.WithEnvironmentUserName()
            .Enrich.WithMachineName()
            .Enrich.WithProcessId()
            .Enrich.WithProcessName()
            .Enrich.WithThreadId();
        }
        /// <summary>
        /// Registers the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Register([NotNull] ISerilogConventionContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var environment = context.Environment;

            context.LoggerConfiguration.Enrich.WithProperty(
                nameof(environment.EnvironmentName),
                environment.EnvironmentName
                );
            context.LoggerConfiguration.Enrich.WithProperty(
                nameof(environment.ApplicationName),
                environment.ApplicationName
                );
        }
Exemple #7
0
 //#endif
 //#if UseSerilog
 public void Register(ISerilogConventionContext context)
 {
 }