mirror of https://github.com/abpframework/abp.git
14 changed files with 266 additions and 387 deletions
@ -1,56 +1,55 @@ |
|||||
using System; |
using System; |
||||
using Microsoft.AspNetCore.Hosting; |
using Microsoft.AspNetCore.Builder; |
||||
using Microsoft.Extensions.Configuration; |
using Microsoft.Extensions.DependencyInjection; |
||||
using Microsoft.Extensions.Hosting; |
using Microsoft.Extensions.Hosting; |
||||
using Serilog; |
using Serilog; |
||||
using Serilog.Events; |
using Serilog.Events; |
||||
|
|
||||
namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered |
namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered; |
||||
|
|
||||
|
public class Program |
||||
{ |
{ |
||||
public class Program |
public static int Main(string[] args) |
||||
{ |
{ |
||||
public static int Main(string[] args) |
Log.Logger = new LoggerConfiguration() |
||||
{ |
|
||||
Log.Logger = new LoggerConfiguration() |
|
||||
#if DEBUG
|
#if DEBUG
|
||||
.MinimumLevel.Debug() |
.MinimumLevel.Debug() |
||||
#else
|
#else
|
||||
.MinimumLevel.Information() |
.MinimumLevel.Information() |
||||
#endif
|
#endif
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
||||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
||||
.Enrich.FromLogContext() |
.Enrich.FromLogContext() |
||||
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
||||
#if DEBUG
|
#if DEBUG
|
||||
.WriteTo.Async(c => c.Console()) |
.WriteTo.Async(c => c.Console()) |
||||
#endif
|
#endif
|
||||
.CreateLogger(); |
.CreateLogger(); |
||||
|
|
||||
try |
|
||||
{ |
|
||||
Log.Information("Starting web host."); |
|
||||
CreateHostBuilder(args).Build().Run(); |
|
||||
return 0; |
|
||||
} |
|
||||
catch (Exception ex) |
|
||||
{ |
|
||||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|
||||
return 1; |
|
||||
} |
|
||||
finally |
|
||||
{ |
|
||||
Log.CloseAndFlush(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) => |
try |
||||
Host.CreateDefaultBuilder(args) |
{ |
||||
.AddAppSettingsSecretsJson() |
Log.Information("Starting web host."); |
||||
.ConfigureWebHostDefaults(webBuilder => |
var builder = WebApplication.CreateBuilder(args); |
||||
{ |
builder.Host.AddAppSettingsSecretsJson() |
||||
webBuilder.UseStartup<Startup>(); |
|
||||
}) |
|
||||
.UseAutofac() |
.UseAutofac() |
||||
.UseSerilog(); |
.UseSerilog(); |
||||
|
builder.Services.AddApplication<MyProjectNameBlazorModule>(options => |
||||
|
{ |
||||
|
options.Services.ReplaceConfiguration(builder.Configuration); |
||||
|
}); |
||||
|
var app = builder.Build(); |
||||
|
app.InitializeApplication(); |
||||
|
app.Run(); |
||||
|
return 0; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.Fatal(ex, "Host terminated unexpectedly!"); |
||||
|
return 1; |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
Log.CloseAndFlush(); |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,19 +0,0 @@ |
|||||
using Microsoft.AspNetCore.Builder; |
|
||||
using Microsoft.AspNetCore.Hosting; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
|
||||
|
|
||||
namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered |
|
||||
{ |
|
||||
public class Startup |
|
||||
{ |
|
||||
public void ConfigureServices(IServiceCollection services) |
|
||||
{ |
|
||||
services.AddApplication<MyProjectNameBlazorModule>(); |
|
||||
} |
|
||||
|
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
|
||||
{ |
|
||||
app.InitializeApplication(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,56 +1,55 @@ |
|||||
using System; |
using System; |
||||
using Microsoft.AspNetCore.Hosting; |
using Microsoft.AspNetCore.Builder; |
||||
using Microsoft.Extensions.Configuration; |
using Microsoft.Extensions.DependencyInjection; |
||||
using Microsoft.Extensions.Hosting; |
using Microsoft.Extensions.Hosting; |
||||
using Serilog; |
using Serilog; |
||||
using Serilog.Events; |
using Serilog.Events; |
||||
|
|
||||
namespace MyCompanyName.MyProjectName.Blazor.Server |
namespace MyCompanyName.MyProjectName.Blazor.Server; |
||||
|
|
||||
|
public class Program |
||||
{ |
{ |
||||
public class Program |
public static int Main(string[] args) |
||||
{ |
{ |
||||
public static int Main(string[] args) |
Log.Logger = new LoggerConfiguration() |
||||
{ |
|
||||
Log.Logger = new LoggerConfiguration() |
|
||||
#if DEBUG
|
#if DEBUG
|
||||
.MinimumLevel.Debug() |
.MinimumLevel.Debug() |
||||
#else
|
#else
|
||||
.MinimumLevel.Information() |
.MinimumLevel.Information() |
||||
#endif
|
#endif
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
||||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
||||
.Enrich.FromLogContext() |
.Enrich.FromLogContext() |
||||
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
||||
#if DEBUG
|
#if DEBUG
|
||||
.WriteTo.Async(c => c.Console()) |
.WriteTo.Async(c => c.Console()) |
||||
#endif
|
#endif
|
||||
.CreateLogger(); |
.CreateLogger(); |
||||
|
|
||||
try |
|
||||
{ |
|
||||
Log.Information("Starting web host."); |
|
||||
CreateHostBuilder(args).Build().Run(); |
|
||||
return 0; |
|
||||
} |
|
||||
catch (Exception ex) |
|
||||
{ |
|
||||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|
||||
return 1; |
|
||||
} |
|
||||
finally |
|
||||
{ |
|
||||
Log.CloseAndFlush(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) => |
try |
||||
Host.CreateDefaultBuilder(args) |
{ |
||||
.AddAppSettingsSecretsJson() |
Log.Information("Starting web host."); |
||||
.ConfigureWebHostDefaults(webBuilder => |
var builder = WebApplication.CreateBuilder(args); |
||||
{ |
builder.Host.AddAppSettingsSecretsJson() |
||||
webBuilder.UseStartup<Startup>(); |
|
||||
}) |
|
||||
.UseAutofac() |
.UseAutofac() |
||||
.UseSerilog(); |
.UseSerilog(); |
||||
|
builder.Services.AddApplication<MyProjectNameBlazorModule>(options => |
||||
|
{ |
||||
|
options.Services.ReplaceConfiguration(builder.Configuration); |
||||
|
}); |
||||
|
var app = builder.Build(); |
||||
|
app.InitializeApplication(); |
||||
|
app.Run(); |
||||
|
return 0; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.Fatal(ex, "Host terminated unexpectedly!"); |
||||
|
return 1; |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
Log.CloseAndFlush(); |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,19 +0,0 @@ |
|||||
using Microsoft.AspNetCore.Builder; |
|
||||
using Microsoft.AspNetCore.Hosting; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
|
||||
|
|
||||
namespace MyCompanyName.MyProjectName.Blazor.Server |
|
||||
{ |
|
||||
public class Startup |
|
||||
{ |
|
||||
public void ConfigureServices(IServiceCollection services) |
|
||||
{ |
|
||||
services.AddApplication<MyProjectNameBlazorModule>(); |
|
||||
} |
|
||||
|
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
|
||||
{ |
|
||||
app.InitializeApplication(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,56 +1,55 @@ |
|||||
using System; |
using System; |
||||
using Microsoft.AspNetCore.Hosting; |
using Microsoft.AspNetCore.Builder; |
||||
using Microsoft.Extensions.Configuration; |
using Microsoft.Extensions.DependencyInjection; |
||||
using Microsoft.Extensions.Hosting; |
using Microsoft.Extensions.Hosting; |
||||
using Serilog; |
using Serilog; |
||||
using Serilog.Events; |
using Serilog.Events; |
||||
|
|
||||
namespace MyCompanyName.MyProjectName |
namespace MyCompanyName.MyProjectName; |
||||
|
|
||||
|
public class Program |
||||
{ |
{ |
||||
public class Program |
public static int Main(string[] args) |
||||
{ |
{ |
||||
public static int Main(string[] args) |
Log.Logger = new LoggerConfiguration() |
||||
{ |
|
||||
Log.Logger = new LoggerConfiguration() |
|
||||
#if DEBUG
|
#if DEBUG
|
||||
.MinimumLevel.Debug() |
.MinimumLevel.Debug() |
||||
#else
|
#else
|
||||
.MinimumLevel.Information() |
.MinimumLevel.Information() |
||||
#endif
|
#endif
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
||||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
||||
.Enrich.FromLogContext() |
.Enrich.FromLogContext() |
||||
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
||||
#if DEBUG
|
#if DEBUG
|
||||
.WriteTo.Async(c => c.Console()) |
.WriteTo.Async(c => c.Console()) |
||||
#endif
|
#endif
|
||||
.CreateLogger(); |
.CreateLogger(); |
||||
|
|
||||
try |
|
||||
{ |
|
||||
Log.Information("Starting MyCompanyName.MyProjectName.HttpApi.Host."); |
|
||||
CreateHostBuilder(args).Build().Run(); |
|
||||
return 0; |
|
||||
} |
|
||||
catch (Exception ex) |
|
||||
{ |
|
||||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|
||||
return 1; |
|
||||
} |
|
||||
finally |
|
||||
{ |
|
||||
Log.CloseAndFlush(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
try |
||||
Host.CreateDefaultBuilder(args) |
{ |
||||
.AddAppSettingsSecretsJson() |
Log.Information("Starting MyCompanyName.MyProjectName.HttpApi.Host."); |
||||
.ConfigureWebHostDefaults(webBuilder => |
var builder = WebApplication.CreateBuilder(args); |
||||
{ |
builder.Host.AddAppSettingsSecretsJson() |
||||
webBuilder.UseStartup<Startup>(); |
|
||||
}) |
|
||||
.UseAutofac() |
.UseAutofac() |
||||
.UseSerilog(); |
.UseSerilog(); |
||||
|
builder.Services.AddApplication<MyProjectNameHttpApiHostModule>(options => |
||||
|
{ |
||||
|
options.Services.ReplaceConfiguration(builder.Configuration); |
||||
|
}); |
||||
|
var app = builder.Build(); |
||||
|
app.InitializeApplication(); |
||||
|
app.Run(); |
||||
|
return 0; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.Fatal(ex, "Host terminated unexpectedly!"); |
||||
|
return 1; |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
Log.CloseAndFlush(); |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,20 +0,0 @@ |
|||||
using Microsoft.AspNetCore.Builder; |
|
||||
using Microsoft.AspNetCore.Hosting; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
|
||||
using Microsoft.Extensions.Logging; |
|
||||
|
|
||||
namespace MyCompanyName.MyProjectName |
|
||||
{ |
|
||||
public class Startup |
|
||||
{ |
|
||||
public void ConfigureServices(IServiceCollection services) |
|
||||
{ |
|
||||
services.AddApplication<MyProjectNameHttpApiHostModule>(); |
|
||||
} |
|
||||
|
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) |
|
||||
{ |
|
||||
app.InitializeApplication(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,56 +1,55 @@ |
|||||
using System; |
using System; |
||||
using Microsoft.AspNetCore.Hosting; |
using Microsoft.AspNetCore.Builder; |
||||
using Microsoft.Extensions.Configuration; |
using Microsoft.Extensions.DependencyInjection; |
||||
using Microsoft.Extensions.Hosting; |
using Microsoft.Extensions.Hosting; |
||||
using Serilog; |
using Serilog; |
||||
using Serilog.Events; |
using Serilog.Events; |
||||
|
|
||||
namespace MyCompanyName.MyProjectName |
namespace MyCompanyName.MyProjectName; |
||||
|
|
||||
|
public class Program |
||||
{ |
{ |
||||
public class Program |
public static int Main(string[] args) |
||||
{ |
{ |
||||
public static int Main(string[] args) |
Log.Logger = new LoggerConfiguration() |
||||
{ |
|
||||
Log.Logger = new LoggerConfiguration() |
|
||||
#if DEBUG
|
#if DEBUG
|
||||
.MinimumLevel.Debug() |
.MinimumLevel.Debug() |
||||
#else
|
#else
|
||||
.MinimumLevel.Information() |
.MinimumLevel.Information() |
||||
#endif
|
#endif
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
||||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
||||
.Enrich.FromLogContext() |
.Enrich.FromLogContext() |
||||
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
||||
#if DEBUG
|
#if DEBUG
|
||||
.WriteTo.Async(c => c.Console()) |
.WriteTo.Async(c => c.Console()) |
||||
#endif
|
#endif
|
||||
.CreateLogger(); |
.CreateLogger(); |
||||
|
|
||||
try |
|
||||
{ |
|
||||
Log.Information("Starting MyCompanyName.MyProjectName.HttpApi.Host."); |
|
||||
CreateHostBuilder(args).Build().Run(); |
|
||||
return 0; |
|
||||
} |
|
||||
catch (Exception ex) |
|
||||
{ |
|
||||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|
||||
return 1; |
|
||||
} |
|
||||
finally |
|
||||
{ |
|
||||
Log.CloseAndFlush(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
try |
||||
Host.CreateDefaultBuilder(args) |
{ |
||||
.AddAppSettingsSecretsJson() |
Log.Information("Starting MyCompanyName.MyProjectName.HttpApi.Host."); |
||||
.ConfigureWebHostDefaults(webBuilder => |
var builder = WebApplication.CreateBuilder(args); |
||||
{ |
builder.Host.AddAppSettingsSecretsJson() |
||||
webBuilder.UseStartup<Startup>(); |
|
||||
}) |
|
||||
.UseAutofac() |
.UseAutofac() |
||||
.UseSerilog(); |
.UseSerilog(); |
||||
|
builder.Services.AddApplication<MyProjectNameHttpApiHostModule>(options => |
||||
|
{ |
||||
|
options.Services.ReplaceConfiguration(builder.Configuration); |
||||
|
}); |
||||
|
var app = builder.Build(); |
||||
|
app.InitializeApplication(); |
||||
|
app.Run(); |
||||
|
return 0; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.Fatal(ex, "Host terminated unexpectedly!"); |
||||
|
return 1; |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
Log.CloseAndFlush(); |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,20 +0,0 @@ |
|||||
using Microsoft.AspNetCore.Builder; |
|
||||
using Microsoft.AspNetCore.Hosting; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
|
||||
using Microsoft.Extensions.Logging; |
|
||||
|
|
||||
namespace MyCompanyName.MyProjectName |
|
||||
{ |
|
||||
public class Startup |
|
||||
{ |
|
||||
public void ConfigureServices(IServiceCollection services) |
|
||||
{ |
|
||||
services.AddApplication<MyProjectNameHttpApiHostModule>(); |
|
||||
} |
|
||||
|
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) |
|
||||
{ |
|
||||
app.InitializeApplication(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,56 +1,55 @@ |
|||||
using System; |
using System; |
||||
using Microsoft.AspNetCore.Hosting; |
using Microsoft.AspNetCore.Builder; |
||||
using Microsoft.Extensions.Configuration; |
using Microsoft.Extensions.DependencyInjection; |
||||
using Microsoft.Extensions.Hosting; |
using Microsoft.Extensions.Hosting; |
||||
using Serilog; |
using Serilog; |
||||
using Serilog.Events; |
using Serilog.Events; |
||||
|
|
||||
namespace MyCompanyName.MyProjectName |
namespace MyCompanyName.MyProjectName; |
||||
|
|
||||
|
public class Program |
||||
{ |
{ |
||||
public class Program |
public static int Main(string[] args) |
||||
{ |
{ |
||||
public static int Main(string[] args) |
Log.Logger = new LoggerConfiguration() |
||||
{ |
|
||||
Log.Logger = new LoggerConfiguration() |
|
||||
#if DEBUG
|
#if DEBUG
|
||||
.MinimumLevel.Debug() |
.MinimumLevel.Debug() |
||||
#else
|
#else
|
||||
.MinimumLevel.Information() |
.MinimumLevel.Information() |
||||
#endif
|
#endif
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
||||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
||||
.Enrich.FromLogContext() |
.Enrich.FromLogContext() |
||||
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
||||
#if DEBUG
|
#if DEBUG
|
||||
.WriteTo.Async(c => c.Console()) |
.WriteTo.Async(c => c.Console()) |
||||
#endif
|
#endif
|
||||
.CreateLogger(); |
.CreateLogger(); |
||||
|
|
||||
try |
|
||||
{ |
|
||||
Log.Information("Starting MyCompanyName.MyProjectName.IdentityServer."); |
|
||||
CreateHostBuilder(args).Build().Run(); |
|
||||
return 0; |
|
||||
} |
|
||||
catch (Exception ex) |
|
||||
{ |
|
||||
Log.Fatal(ex, "MyCompanyName.MyProjectName.IdentityServer terminated unexpectedly!"); |
|
||||
return 1; |
|
||||
} |
|
||||
finally |
|
||||
{ |
|
||||
Log.CloseAndFlush(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
try |
||||
Host.CreateDefaultBuilder(args) |
{ |
||||
.AddAppSettingsSecretsJson() |
Log.Information("Starting MyCompanyName.MyProjectName.IdentityServer."); |
||||
.ConfigureWebHostDefaults(webBuilder => |
var builder = WebApplication.CreateBuilder(args); |
||||
{ |
builder.Host.AddAppSettingsSecretsJson() |
||||
webBuilder.UseStartup<Startup>(); |
|
||||
}) |
|
||||
.UseAutofac() |
.UseAutofac() |
||||
.UseSerilog(); |
.UseSerilog(); |
||||
|
builder.Services.AddApplication<MyProjectNameIdentityServerModule>(options => |
||||
|
{ |
||||
|
options.Services.ReplaceConfiguration(builder.Configuration); |
||||
|
}); |
||||
|
var app = builder.Build(); |
||||
|
app.InitializeApplication(); |
||||
|
app.Run(); |
||||
|
return 0; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.Fatal(ex, "MyCompanyName.MyProjectName.IdentityServer terminated unexpectedly!"); |
||||
|
return 1; |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
Log.CloseAndFlush(); |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,18 +0,0 @@ |
|||||
using Microsoft.AspNetCore.Builder; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
|
||||
|
|
||||
namespace MyCompanyName.MyProjectName |
|
||||
{ |
|
||||
public class Startup |
|
||||
{ |
|
||||
public void ConfigureServices(IServiceCollection services) |
|
||||
{ |
|
||||
services.AddApplication<MyProjectNameIdentityServerModule>(); |
|
||||
} |
|
||||
|
|
||||
public void Configure(IApplicationBuilder app) |
|
||||
{ |
|
||||
app.InitializeApplication(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,56 +1,55 @@ |
|||||
using System; |
using System; |
||||
using Microsoft.AspNetCore.Hosting; |
using Microsoft.AspNetCore.Builder; |
||||
using Microsoft.Extensions.Configuration; |
using Microsoft.Extensions.DependencyInjection; |
||||
using Microsoft.Extensions.Hosting; |
using Microsoft.Extensions.Hosting; |
||||
using Serilog; |
using Serilog; |
||||
using Serilog.Events; |
using Serilog.Events; |
||||
|
|
||||
namespace MyCompanyName.MyProjectName.Web |
namespace MyCompanyName.MyProjectName.Web; |
||||
|
|
||||
|
public class Program |
||||
{ |
{ |
||||
public class Program |
public static int Main(string[] args) |
||||
{ |
{ |
||||
public static int Main(string[] args) |
Log.Logger = new LoggerConfiguration() |
||||
{ |
|
||||
Log.Logger = new LoggerConfiguration() |
|
||||
#if DEBUG
|
#if DEBUG
|
||||
.MinimumLevel.Debug() |
.MinimumLevel.Debug() |
||||
#else
|
#else
|
||||
.MinimumLevel.Information() |
.MinimumLevel.Information() |
||||
#endif
|
#endif
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
||||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
||||
.Enrich.FromLogContext() |
.Enrich.FromLogContext() |
||||
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
||||
#if DEBUG
|
#if DEBUG
|
||||
.WriteTo.Async(c => c.Console()) |
.WriteTo.Async(c => c.Console()) |
||||
#endif
|
#endif
|
||||
.CreateLogger(); |
.CreateLogger(); |
||||
|
|
||||
try |
|
||||
{ |
|
||||
Log.Information("Starting web host."); |
|
||||
CreateHostBuilder(args).Build().Run(); |
|
||||
return 0; |
|
||||
} |
|
||||
catch (Exception ex) |
|
||||
{ |
|
||||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|
||||
return 1; |
|
||||
} |
|
||||
finally |
|
||||
{ |
|
||||
Log.CloseAndFlush(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
try |
||||
Host.CreateDefaultBuilder(args) |
{ |
||||
.AddAppSettingsSecretsJson() |
Log.Information("Starting web host."); |
||||
.ConfigureWebHostDefaults(webBuilder => |
var builder = WebApplication.CreateBuilder(args); |
||||
{ |
builder.Host.AddAppSettingsSecretsJson() |
||||
webBuilder.UseStartup<Startup>(); |
|
||||
}) |
|
||||
.UseAutofac() |
.UseAutofac() |
||||
.UseSerilog(); |
.UseSerilog(); |
||||
|
builder.Services.AddApplication<MyProjectNameWebModule>(options => |
||||
|
{ |
||||
|
options.Services.ReplaceConfiguration(builder.Configuration); |
||||
|
}); |
||||
|
var app = builder.Build(); |
||||
|
app.InitializeApplication(); |
||||
|
app.Run(); |
||||
|
return 0; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.Fatal(ex, "Host terminated unexpectedly!"); |
||||
|
return 1; |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
Log.CloseAndFlush(); |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,19 +0,0 @@ |
|||||
using Microsoft.AspNetCore.Builder; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
|
||||
using Microsoft.Extensions.Logging; |
|
||||
|
|
||||
namespace MyCompanyName.MyProjectName.Web |
|
||||
{ |
|
||||
public class Startup |
|
||||
{ |
|
||||
public void ConfigureServices(IServiceCollection services) |
|
||||
{ |
|
||||
services.AddApplication<MyProjectNameWebModule>(); |
|
||||
} |
|
||||
|
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) |
|
||||
{ |
|
||||
app.InitializeApplication(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,55 +1,55 @@ |
|||||
using System; |
using System; |
||||
using Microsoft.AspNetCore.Builder; |
using Microsoft.AspNetCore.Builder; |
||||
using Microsoft.AspNetCore.Hosting; |
|
||||
using Microsoft.Extensions.Configuration; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
using Microsoft.Extensions.DependencyInjection; |
||||
using Microsoft.Extensions.Hosting; |
using Microsoft.Extensions.Hosting; |
||||
using Serilog; |
using Serilog; |
||||
using Serilog.Events; |
using Serilog.Events; |
||||
|
|
||||
namespace MyCompanyName.MyProjectName.Web |
namespace MyCompanyName.MyProjectName.Web; |
||||
|
|
||||
|
public class Program |
||||
{ |
{ |
||||
public class Program |
public static int Main(string[] args) |
||||
{ |
{ |
||||
public static int Main(string[] args) |
Log.Logger = new LoggerConfiguration() |
||||
{ |
|
||||
Log.Logger = new LoggerConfiguration() |
|
||||
#if DEBUG
|
#if DEBUG
|
||||
.MinimumLevel.Debug() |
.MinimumLevel.Debug() |
||||
#else
|
#else
|
||||
.MinimumLevel.Information() |
.MinimumLevel.Information() |
||||
#endif
|
#endif
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
||||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
||||
.Enrich.FromLogContext() |
.Enrich.FromLogContext() |
||||
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
||||
#if DEBUG
|
#if DEBUG
|
||||
.WriteTo.Async(c => c.Console()) |
.WriteTo.Async(c => c.Console()) |
||||
#endif
|
#endif
|
||||
.CreateLogger(); |
.CreateLogger(); |
||||
|
|
||||
try |
try |
||||
{ |
{ |
||||
Log.Information("Starting web host."); |
Log.Information("Starting web host."); |
||||
var builder = WebApplication.CreateBuilder(args); |
var builder = WebApplication.CreateBuilder(args); |
||||
builder.Host.AddAppSettingsSecretsJson() |
builder.Host.AddAppSettingsSecretsJson() |
||||
.UseAutofac() |
.UseAutofac() |
||||
.UseSerilog(); |
.UseSerilog(); |
||||
builder.Services.AddApplication<MyProjectNameWebModule>(); |
builder.Services.AddApplication<MyProjectNameWebModule>(options => |
||||
var app = builder.Build(); |
|
||||
app.InitializeApplication(); |
|
||||
app.Run(); |
|
||||
return 0; |
|
||||
} |
|
||||
catch (Exception ex) |
|
||||
{ |
|
||||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|
||||
return 1; |
|
||||
} |
|
||||
finally |
|
||||
{ |
{ |
||||
Log.CloseAndFlush(); |
options.Services.ReplaceConfiguration(builder.Configuration); |
||||
} |
}); |
||||
|
var app = builder.Build(); |
||||
|
app.InitializeApplication(); |
||||
|
app.Run(); |
||||
|
return 0; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Log.Fatal(ex, "Host terminated unexpectedly!"); |
||||
|
return 1; |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
Log.CloseAndFlush(); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue