Example #1
0
        public Startup(IHostingEnvironment env)
        {
            _environment = env;

            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddJsonFile($"appsettings.private.json", optional: true);

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();

            //Logging bootstraping
            _logManager = new LMS.Utilities.Logging.LogManager();
            var section = Configuration.GetSection("Logging");
            // clear text keys from 'Logging:' prefix
            var path = section.Path + ":";

            _logManager.Configure(section.AsEnumerable().Select(x => new KeyValuePair <string, string>(x.Key.Replace(path, ""), x.Value)));

            _logManager.GetLogger().Warn("LMS.Web is starting");

            //DB check and recreate
            CheckDb <LmsDbContext>(Configuration.GetConnectionString("DefaultConnection"));
            CheckDb <AppDbContext>(Configuration.GetConnectionString("DefaultConnection"));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="logManager"></param>
        /// <param name="globalLogSettings"></param>
        /// <returns></returns>
        // ReSharper disable once UnusedMember.Global
        public static ILogManager ConfigureLogging(this ILogManager logManager,
                                                   ILogOptions globalLogSettings)
        {
            Ensure.Argument.NotNull(logManager, nameof(logManager));

            logManager.Configure(globalLogSettings);

            return(logManager);
        }