예제 #1
0
        public static void UseSeriLog(this IServiceCollection services, LoggerConfiguration configuration)
        {
            // todo: serilog integration into routine, extract
            services.AddSingleton <ILoggerFactory>(collection =>
            {
                var loggerSettings = collection.GetService <ApplicationSettings>().Logging;
                configuration.Configure(loggerSettings);

                return(new SerilogLoggerFactory(Log.Logger, true));
            });
        }
예제 #2
0
        public void Configure(IDependencyContainer container)
        {
            container.ThrowIfNull();

            var configuration = new LoggerConfiguration();

            configuration.Configure();
            (container as DependencyContainer).UnityContainer.AddExtension(new LoggerConstructorInjectionExtension());

            container.Register.Instance <ILoggerFactory>(new LoggerFactory());
        }
예제 #3
0
 /// <summary>
 /// Create trace logger
 /// </summary>
 /// <param name="configuration"></param>
 /// <param name="addConsole"></param>
 /// <returns></returns>
 public static LoggerConfiguration Debug(this LoggerConfiguration configuration,
                                         bool addConsole = true)
 {
     return(configuration.Configure((c, m) => c
                                    .WriteTo.Debug(outputTemplate: m), addConsole));
 }