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.
42 lines
1.5 KiB
42 lines
1.5 KiB
using LINGYUN.Abp.MicroService.MessageService;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using Serilog;
|
|
using Serilog.Events;
|
|
|
|
var defaultOutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}";
|
|
|
|
Log.Logger = new LoggerConfiguration()
|
|
.MinimumLevel.Information()
|
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
|
|
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning)
|
|
#if DEBUG
|
|
.MinimumLevel.Override("LINGYUN.Abp.MicroService.MessageService", LogEventLevel.Debug)
|
|
#else
|
|
.MinimumLevel.Override("LINGYUN.Abp.MicroService.MessageService", LogEventLevel.Information)
|
|
#endif
|
|
.Enrich.FromLogContext()
|
|
.WriteTo.Async(x => x.Console(outputTemplate: defaultOutputTemplate))
|
|
.WriteTo.Async(x => x.File("Logs/migrations.txt", outputTemplate: defaultOutputTemplate))
|
|
.CreateLogger();
|
|
|
|
try
|
|
{
|
|
var builder = Host.CreateDefaultBuilder(args)
|
|
.AddAppSettingsSecretsJson()
|
|
.ConfigureLogging((context, logging) => logging.ClearProviders())
|
|
.ConfigureServices((hostContext, services) =>
|
|
{
|
|
services.AddHostedService<MessageServiceDbMigratorHostedService>();
|
|
});
|
|
await builder.RunConsoleAsync();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Fatal(ex, "Host terminated unexpectedly!");
|
|
}
|
|
finally
|
|
{
|
|
await Log.CloseAndFlushAsync();
|
|
}
|