public static void Main(string[] args) { //Build config to get config files var config = new ConfigurationBuilder() .SetBasePath(Environment.CurrentDirectory) .AddJsonFile("appsettings.json", optional: false) .Build(); var instrumentationConfig = new InstrumentationConfiguration(); //Map instrumentationConfiguration section into config file config.GetSection(nameof(InstrumentationConfiguration)).Bind(instrumentationConfig); //Initiate config with configSection Log.Logger = LoggingConfiguration.GetConfiguration(instrumentationConfig).CreateLogger(); try { Log.Information("Starting API host"); CreateWebHostBuilder(args).Build().Run(); } catch (Exception e) { Log.Fatal(e, "API host could not start or terminated unexpectedly"); } finally { Log.CloseAndFlush(); } }
public void Configuration(IAppBuilder app) { LMSCoreModule.CurrentLogLevel = new LoggingLevelSwitch(); bool debug = ConfigurationManager.AppSettings.Get("Debug").To <bool>(); if (debug) { LMSCoreModule.CurrentLogLevel.MinimumLevel = LogEventLevel.Verbose; } app.UseAbp <LMSServiceModule>(a => { a.IocManager.IocContainer.Register( LoggingConfiguration.GetConfiguration(LMSCoreModule.CurrentLogLevel) ); }); app.UseHangfireDashboard(""); }
public static void Run(RunOptions opts) { LMSCoreModule.CurrentLogLevel = new LoggingLevelSwitch(); using (AbpBootstrapper bootstrapper = AbpBootstrapper.Create <LMSServiceModule>()) { bootstrapper.Initialize(); bootstrapper.IocManager.IocContainer.Register( LoggingConfiguration.GetConfiguration(LMSCoreModule.CurrentLogLevel) ); if (opts.Verbose) { LMSCoreModule.CurrentLogLevel.MinimumLevel = LogEventLevel.Debug; LogHelper.Logger.Debug("Verbose logging enabled."); } LogHelper.Logger.Info($"Version: {AppVersionHelper.Version} Release: {AppVersionHelper.ReleaseDate}"); using (var iocResolver = bootstrapper.IocManager.ResolveAsDisposable <IIocResolver>()) { using (var scope = iocResolver.Object.CreateScope()) { if (!opts.SkipStartup) { var startupManager = scope.Resolve <IStartupManager>(); bool started = startupManager.Init(null); if (!started) { return; } } try { if (opts.Monitor == Monitor.Users) { var userWorkerManager = scope.Resolve <UserWorkerManager>(); AsyncHelper.RunSync(() => userWorkerManager.StartAsync(null)); return; } if (opts.Monitor == Monitor.Veeam) { var veeamWorkerManager = scope.Resolve <VeeamWorkerManager>(); AsyncHelper.RunSync(() => veeamWorkerManager.StartAsync(null)); return; } Console.WriteLine("Press [Enter] to continue."); Console.ReadLine(); } catch (Exception ex) { LogHelper.LogException(ex); LogHelper.Logger.Debug(ex.Message, ex); LogHelper.Logger.Error("************ Failed ************"); } } } } }