-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
21,707 additions
and
8,478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,56 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Serilog; | ||
using Volo.Abp; | ||
using Serilog.Events; | ||
|
||
namespace App1 | ||
namespace App1; | ||
|
||
public class Program | ||
{ | ||
internal class Program | ||
public async static Task<int> Main(string[] args) | ||
{ | ||
public static int Main(string[] args) | ||
Log.Logger = new LoggerConfiguration() | ||
#if DEBUG | ||
.MinimumLevel.Debug() | ||
#else | ||
.MinimumLevel.Information() | ||
#endif | ||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) | ||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) | ||
.Enrich.FromLogContext() | ||
.WriteTo.Async(c => c.File("Logs/logs.txt")) | ||
.WriteTo.Async(c => c.Console()) | ||
.CreateLogger(); | ||
|
||
try | ||
{ | ||
CreateLoggerUsingJSONFile(); | ||
try | ||
{ | ||
Log.Information("Starting App1.WebHost."); | ||
CreateHostBuilder(args, Log.Logger).Build().Run(); | ||
return 0; | ||
} | ||
catch (Exception ex) | ||
{ | ||
return 1; | ||
} | ||
finally | ||
Log.Information("Starting web host."); | ||
var builder = WebApplication.CreateBuilder(args); | ||
builder.Host.AddAppSettingsSecretsJson() | ||
.UseAutofac() | ||
.UseSerilog(); | ||
await builder.AddApplicationAsync<App1Module>(); | ||
var app = builder.Build(); | ||
await app.InitializeApplicationAsync(); | ||
await app.RunAsync(); | ||
return 0; | ||
} | ||
catch (Exception ex) | ||
{ | ||
if (ex is HostAbortedException) | ||
{ | ||
Log.CloseAndFlush(); | ||
throw; | ||
} | ||
} | ||
|
||
internal static IHostBuilder CreateHostBuilder(string[] args, ILogger logger) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}) | ||
.UseAutofac() | ||
.UseSerilog(logger); | ||
|
||
|
||
private static void CreateLoggerUsingJSONFile() | ||
Log.Fatal(ex, "Host terminated unexpectedly!"); | ||
return 1; | ||
} | ||
finally | ||
{ | ||
var configuration = new ConfigurationBuilder() | ||
.AddJsonFile("appsettings.json").Build(); | ||
|
||
Log.Logger = new LoggerConfiguration() | ||
.ReadFrom | ||
.Configuration(configuration).CreateLogger(); | ||
Log.CloseAndFlush(); | ||
} | ||
|
||
|
||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Serilog; | ||
using Volo.Abp; | ||
using Serilog.Events; | ||
|
||
namespace App2 | ||
namespace App2; | ||
|
||
public class Program | ||
{ | ||
internal class Program | ||
public async static Task<int> Main(string[] args) | ||
{ | ||
public static int Main(string[] args) | ||
Log.Logger = new LoggerConfiguration() | ||
#if DEBUG | ||
.MinimumLevel.Debug() | ||
#else | ||
.MinimumLevel.Information() | ||
#endif | ||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) | ||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) | ||
.Enrich.FromLogContext() | ||
.WriteTo.Async(c => c.File("Logs/logs.txt")) | ||
.WriteTo.Async(c => c.Console()) | ||
.CreateLogger(); | ||
|
||
try | ||
{ | ||
CreateLoggerUsingJSONFile(); | ||
try | ||
{ | ||
Log.Information("Starting App2.WebHost."); | ||
CreateHostBuilder(args, Log.Logger) | ||
.Build() | ||
.Run(); | ||
return 0; | ||
} | ||
catch (Exception ex) | ||
{ | ||
return 1; | ||
} | ||
finally | ||
Log.Information("Starting web host."); | ||
var builder = WebApplication.CreateBuilder(args); | ||
builder.Host.AddAppSettingsSecretsJson() | ||
.UseAutofac() | ||
.UseSerilog(); | ||
await builder.AddApplicationAsync<App2Module>(); | ||
var app = builder.Build(); | ||
await app.InitializeApplicationAsync(); | ||
await app.RunAsync(); | ||
return 0; | ||
} | ||
catch (Exception ex) | ||
{ | ||
if (ex is HostAbortedException) | ||
{ | ||
Log.CloseAndFlush(); | ||
throw; | ||
} | ||
} | ||
|
||
internal static IHostBuilder CreateHostBuilder(string[] args, ILogger logger) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}) | ||
.UseAutofac() | ||
.UseSerilog(logger); | ||
|
||
|
||
private static void CreateLoggerUsingJSONFile() | ||
Log.Fatal(ex, "Host terminated unexpectedly!"); | ||
return 1; | ||
} | ||
finally | ||
{ | ||
var configuration = new ConfigurationBuilder() | ||
.AddJsonFile("appsettings.json").Build(); | ||
|
||
Log.Logger = new LoggerConfiguration() | ||
.ReadFrom | ||
.Configuration(configuration).CreateLogger(); | ||
Log.CloseAndFlush(); | ||
} | ||
|
||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.