|
|
@ -1,14 +1,14 @@ |
|
|
using System.IO; |
|
|
|
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
using Microsoft.Extensions.Hosting; |
|
|
using Microsoft.Extensions.Hosting; |
|
|
|
|
|
using Microsoft.Extensions.Logging; |
|
|
using Serilog; |
|
|
using Serilog; |
|
|
using Serilog.Events; |
|
|
using Serilog.Events; |
|
|
|
|
|
|
|
|
namespace EShopSample.DbMigrator |
|
|
namespace EShopSample.DbMigrator; |
|
|
|
|
|
|
|
|
|
|
|
class Program |
|
|
{ |
|
|
{ |
|
|
class Program |
|
|
|
|
|
{ |
|
|
|
|
|
static async Task Main(string[] args) |
|
|
static async Task Main(string[] args) |
|
|
{ |
|
|
{ |
|
|
Log.Logger = new LoggerConfiguration() |
|
|
Log.Logger = new LoggerConfiguration() |
|
|
@ -21,8 +21,8 @@ namespace EShopSample.DbMigrator |
|
|
.MinimumLevel.Override("EShopSample", LogEventLevel.Information) |
|
|
.MinimumLevel.Override("EShopSample", LogEventLevel.Information) |
|
|
#endif
|
|
|
#endif
|
|
|
.Enrich.FromLogContext() |
|
|
.Enrich.FromLogContext() |
|
|
.WriteTo.File(Path.Combine(Directory.GetCurrentDirectory(), "Logs/logs.txt")) |
|
|
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
|
|
.WriteTo.Console() |
|
|
.WriteTo.Async(c => c.Console()) |
|
|
.CreateLogger(); |
|
|
.CreateLogger(); |
|
|
|
|
|
|
|
|
await CreateHostBuilder(args).RunConsoleAsync(); |
|
|
await CreateHostBuilder(args).RunConsoleAsync(); |
|
|
@ -30,9 +30,10 @@ namespace EShopSample.DbMigrator |
|
|
|
|
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) => |
|
|
public static IHostBuilder CreateHostBuilder(string[] args) => |
|
|
Host.CreateDefaultBuilder(args) |
|
|
Host.CreateDefaultBuilder(args) |
|
|
|
|
|
.AddAppSettingsSecretsJson() |
|
|
|
|
|
.ConfigureLogging((context, logging) => logging.ClearProviders()) |
|
|
.ConfigureServices((hostContext, services) => |
|
|
.ConfigureServices((hostContext, services) => |
|
|
{ |
|
|
{ |
|
|
services.AddHostedService<DbMigratorHostedService>(); |
|
|
services.AddHostedService<DbMigratorHostedService>(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
} |
|
|
} |