Пример #1
0
        private static ILog ConfigureLog(ApplicationSettings settings, LogAggregate logAggregate, ILog log)
        {
            log.Info("Initializing azure/slack logger.", Program.Name);
            var services = new ServiceCollection(); // only used for azure logger

            logAggregate.ConfigureAzureLogger(services, Program.Name, settings);
            return(logAggregate.CreateLogger());
        }
Пример #2
0
        public static void Main(string[] args)
        {
            // Initialize logger
            var consoleLog   = new LogToConsole();
            var logAggregate = new LogAggregate()
                               .AddLogger(consoleLog);
            var log = logAggregate.CreateLogger();

            try
            {
                log.Info("Reading application settings.");
                var config = new ConfigurationBuilder()
                             //.AddJsonFile("appsettings.json", optional: true)
                             .AddEnvironmentVariables()
                             .Build();

                var settingsUrl = config.GetValue <string>("BROKER_SETTINGS_URL");

                log.Info("Loading app settings from web-site.");
                var appSettings = LoadSettings(settingsUrl);

                log.Info("Initializing azure/slack logger.");
                var services = new ServiceCollection(); // only used for azure logger
                logAggregate.ConfigureAzureLogger(services, Startup.ApplicationName, appSettings);

                log = logAggregate.CreateLogger();

                // After log is configured
                //
                log.Info("Creating Startup.");
                var startup = new Startup(appSettings, log);

                log.Info("Configure startup services.");
                startup.ConfigureServices(Application.Instance.ContainerBuilder, log);

                log.Info("Starting application.");
                var scope = Application.Instance.Start();

                log.Info("Configure startup.");
                startup.Configure(scope);

                log.Info("Running application.");
                Application.Instance.Run();

                log.Info("Exit application.");
            }
            catch (Exception ex)
            {
                log.WriteErrorAsync("Program", string.Empty, string.Empty, ex).Wait();
            }
        }