예제 #1
0
        internal static FrameworkConstruction Configure(this FrameworkConstruction construction,
                                                        Action <IConfigurationBuilder> configure = null)
        {
            var configurationBuilder = new ConfigurationBuilder()
                                       .AddEnvironmentVariables()
                                       .AddJsonFile("appsettings.json", true, true)
                                       .AddJsonFile($"appsettings.{construction.Environment.Environment}.json", true, true);

            configure?.Invoke(configurationBuilder);

            var configuration = configurationBuilder.Build();

            construction.Services.AddSingleton <IConfiguration>(configuration);

            construction.Configuration = configuration;
            return(construction);
        }
예제 #2
0
        internal static FrameworkConstruction UseDefaultLogger(this FrameworkConstruction construction)
        {
            #region Serilog settings.
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
                         .Enrich.FromLogContext()
                         .WriteTo.Console()
                         .WriteTo.File(Path.Combine("logs", "log.txt"),
                                       rollingInterval: RollingInterval.Day,
                                       rollOnFileSizeLimit: true)
                         .CreateLogger();
            #endregion

            construction.Services.AddLogging(opt =>
            {
                opt.AddConfiguration(construction.Configuration?.GetSection("Logging"));
                opt.AddSerilog(Log.Logger);
            });

            construction.Services.AddTransient(sp => sp.GetRequiredService <ILoggerFactory>().CreateLogger("dnc"));
            return(construction);
        }
예제 #3
0
파일: Fx.cs 프로젝트: wwwK/Dnc.Core
 public static void Build(this FrameworkConstruction construction, bool logStarted = true)
 {
     construction.ConfigureBuild(fxConstruction => fxConstruction.Services.BuildServiceProvider());
 }