45 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Microsoft.Extensions.DependencyInjection;
 | |
| using Microsoft.Extensions.Hosting;
 | |
| using Microsoft.Extensions.Logging;
 | |
| using Serilog;
 | |
| using Serilog.Events;
 | |
| using System;
 | |
| using System.Threading.Tasks;
 | |
| 
 | |
| namespace KonSoft.Shared.DbMigrator;
 | |
| 
 | |
| class Program
 | |
| {
 | |
|     static async Task Main(string[] args)
 | |
|     {
 | |
|         Log.Logger = new LoggerConfiguration()
 | |
|             .MinimumLevel.Information()
 | |
|             .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
 | |
|             .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning)
 | |
| #if DEBUG
 | |
|             .MinimumLevel.Override("KonSoft.Clean", LogEventLevel.Debug)
 | |
| #else
 | |
|             .MinimumLevel.Override("KonSoft.Clean", LogEventLevel.Information)
 | |
| #endif
 | |
|             .Enrich.FromLogContext()
 | |
|             .WriteTo.Async(c => c.File("Logs/logs.txt"))
 | |
|             .WriteTo.Async(c => c.Console())
 | |
|             .CreateLogger();
 | |
| 
 | |
|         await CreateHostBuilder(args).RunConsoleAsync();
 | |
|     }
 | |
| 
 | |
|     private static IHostBuilder CreateHostBuilder(string[] args) =>
 | |
|         Host.CreateDefaultBuilder(args)
 | |
|             .UseAgileConfig(options =>
 | |
|             {
 | |
|                 options.ENV = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development";
 | |
|             })
 | |
|             .AddAppSettingsSecretsJson()
 | |
|             .ConfigureLogging((context, logging) => logging.ClearProviders())
 | |
|             .ConfigureServices((hostContext, services) =>
 | |
|             {
 | |
|                 services.AddHostedService<DbMigratorHostedService>();
 | |
|             });
 | |
| }
 |