|
1 | | -using Azure.Identity; |
2 | 1 | using Serilog; |
| 2 | +using System.Globalization; |
3 | 3 | using WebCodeFlowPkceClient; |
4 | 4 |
|
5 | 5 | Log.Logger = new LoggerConfiguration() |
6 | | - .WriteTo.Console() |
7 | | - .WriteTo.AzureApp() |
| 6 | + .WriteTo.Console(formatProvider: CultureInfo.InvariantCulture) |
8 | 7 | .CreateBootstrapLogger(); |
9 | 8 |
|
| 9 | +Log.Information("Starting WebCodeFlowPkceClient provider server"); |
| 10 | + |
10 | 11 | try |
11 | 12 | { |
12 | | - Log.Information("Starting WebHybridClient"); |
13 | | - |
14 | 13 | var builder = WebApplication.CreateBuilder(args); |
15 | 14 |
|
16 | | - builder.WebHost |
17 | | - .ConfigureKestrel(serverOptions => { serverOptions.AddServerHeader = false; }) |
18 | | - .ConfigureAppConfiguration((context, configurationBuilder) => |
19 | | - { |
20 | | - var config = configurationBuilder.Build(); |
21 | | - var azureKeyVaultEndpoint = config["AzureKeyVaultEndpoint"]; |
22 | | - if (!string.IsNullOrEmpty(azureKeyVaultEndpoint)) |
23 | | - { |
24 | | - // Add Secrets from KeyVault |
25 | | - Log.Information("Use secrets from {AzureKeyVaultEndpoint}", azureKeyVaultEndpoint); |
26 | | - configurationBuilder.AddAzureKeyVault(new Uri(azureKeyVaultEndpoint), new DefaultAzureCredential()); |
27 | | - } |
28 | | - else |
29 | | - { |
30 | | - // Add Secrets from UserSecrets for local development |
31 | | - configurationBuilder.AddUserSecrets("4bd68e8b-ec2d-42d4-899f-fa77fcd14af5"); |
32 | | - } |
33 | | - }); |
34 | | - |
35 | 15 | builder.Host.UseSerilog((context, loggerConfiguration) => loggerConfiguration |
| 16 | + .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", formatProvider: CultureInfo.InvariantCulture) |
36 | 17 | .ReadFrom.Configuration(context.Configuration)); |
37 | 18 |
|
38 | 19 | var app = builder |
39 | 20 | .ConfigureServices() |
40 | 21 | .ConfigurePipeline(); |
41 | 22 |
|
42 | | - app.Run(); |
| 23 | + await app.RunAsync(); |
43 | 24 | } |
44 | | -catch (Exception ex) when (ex.GetType().Name is not "StopTheHostException" |
45 | | - && ex.GetType().Name is not "HostAbortedException") |
| 25 | +catch (Exception ex) when (ex.GetType().Name is not "StopTheHostException" && ex.GetType().Name is not "HostAbortedException") |
46 | 26 | { |
47 | 27 | Log.Fatal(ex, "Unhandled exception"); |
48 | 28 | } |
49 | 29 | finally |
50 | 30 | { |
51 | 31 | Log.Information("Shut down complete"); |
52 | | - Log.CloseAndFlush(); |
| 32 | + await Log.CloseAndFlushAsync(); |
53 | 33 | } |
0 commit comments