You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.5 KiB
40 lines
1.5 KiB
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using Serilog;
|
|
using Serilog.Events;
|
|
|
|
namespace LY.MicroService.RealtimeMessage.DbMigrator;
|
|
|
|
public class Program
|
|
{
|
|
public async static 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("LY.MicroService.RealtimeMessage.DbMigrator", LogEventLevel.Debug)
|
|
#else
|
|
.MinimumLevel.Override("LY.MicroService.RealtimeMessage.DbMigrator", LogEventLevel.Information)
|
|
#endif
|
|
.Enrich.FromLogContext()
|
|
.WriteTo.Console(outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}")
|
|
.WriteTo.File("Logs/migrations.txt")
|
|
.CreateLogger();
|
|
|
|
await CreateHostBuilder(args).RunConsoleAsync();
|
|
}
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args)
|
|
{
|
|
return Host.CreateDefaultBuilder(args)
|
|
.AddAppSettingsSecretsJson()
|
|
.ConfigureLogging((context, logging) => logging.ClearProviders())
|
|
.ConfigureServices((hostContext, services) =>
|
|
{
|
|
services.AddHostedService<RealtimeMessageDbMigratorHostedService>();
|
|
});
|
|
}
|
|
}
|
|
|