1+ using System ;
2+ using System . Diagnostics ;
3+ using System . Reflection ;
14using Demo . Data ;
25using Microsoft . AspNetCore . Builder ;
36using Microsoft . AspNetCore . Identity ;
47using Microsoft . EntityFrameworkCore ;
58using Microsoft . Extensions . Configuration ;
69using Microsoft . Extensions . DependencyInjection ;
710using Microsoft . Extensions . Hosting ;
11+ using Microsoft . Extensions . Logging ;
812using Myvas . AspNetCore . Authentication ;
913using Myvas . AspNetCore . Weixin ;
1014
@@ -14,6 +18,21 @@ public static class HostExtensions
1418{
1519 public static WebApplicationBuilder ConfigureServices ( this WebApplicationBuilder builder )
1620 {
21+ Debug . WriteLine ( "Create a temporary logger for me." ) ;
22+ // Build a temporary logger for me.
23+ using var loggerFactory = LoggerFactory . Create ( logging =>
24+ {
25+ logging . AddConsole ( ) ;
26+ #if DEBUG
27+ logging . SetMinimumLevel ( LogLevel . Trace ) ;
28+ #else
29+ logging . SetMinimumLevel ( LogLevel . Information ) ;
30+ #endif
31+ } ) ;
32+ var logger = loggerFactory . CreateLogger < WebApplicationBuilder > ( ) ;
33+ logger . LogDebug ( $ "{ MethodBase . GetCurrentMethod ( ) . Name } ...") ;
34+ logger . LogInformation ( "Environment=" + builder . Environment . EnvironmentName ) ;
35+
1736 var Configuration = builder . Configuration ;
1837
1938 builder . Services . AddControllersWithViews ( ) ;
@@ -47,6 +66,10 @@ public static WebApplicationBuilder ConfigureServices(this WebApplicationBuilder
4766 o . AccessDeniedPath = "/Identity/Account/AccessDenied" ;
4867 } ) ;
4968
69+ logger ? . LogInformation ( "WeixinOpen:AppId=" + Configuration [ "WeixinOpen:AppId" ] ) ;
70+ logger ? . LogInformation ( "WeixinAuth:AppId=" + Configuration [ "WeixinAuth:AppId" ] ) ;
71+ logger ? . LogInformation ( "QQConnect:AppId=" + Configuration [ "QQConnect:AppId" ] ) ;
72+
5073 builder . Services . AddAuthentication ( )
5174 . AddWeixinOpen ( o =>
5275 {
@@ -74,6 +97,8 @@ public static WebApplicationBuilder ConfigureServices(this WebApplicationBuilder
7497 QQConnectScopes . do_like ) ;
7598 } ) ;
7699
100+ logger ? . LogInformation ( "TencensSms:SdkAppId=" + Configuration [ "TencentSms:SdkAppId" ] ) ;
101+
77102 builder . Services . AddTencentSms ( o =>
78103 {
79104 o . SdkAppId = Configuration [ "TencentSms:SdkAppId" ] ;
@@ -82,6 +107,8 @@ public static WebApplicationBuilder ConfigureServices(this WebApplicationBuilder
82107
83108 builder . Services . AddViewDivert ( ) ;
84109
110+ logger ? . LogInformation ( "Weixin:AppId=" + Configuration [ "Weixin:AppId" ] ) ;
111+
85112 builder . Services . AddWeixin ( o =>
86113 {
87114 o . AppId = Configuration [ "Weixin:AppId" ] ;
@@ -111,6 +138,10 @@ public static WebApplicationBuilder ConfigureServices(this WebApplicationBuilder
111138
112139 public static WebApplication ConfigurePipeline ( this WebApplication app )
113140 {
141+ var logger = app . Logger ;
142+ logger . LogTrace ( $ "{ MethodBase . GetCurrentMethod ( ) . Name } ...") ;
143+ logger . LogInformation ( $ "Environment={ app . Environment . EnvironmentName } ") ;
144+
114145 var env = app . Environment ;
115146 if ( env . IsDevelopment ( ) )
116147 {
@@ -124,6 +155,8 @@ public static WebApplication ConfigurePipeline(this WebApplication app)
124155 }
125156 //app.UseHttpsRedirection();
126157 app . UseStaticFiles ( ) ;
158+
159+ logger . LogTrace ( "UseWeixinSite..." ) ;
127160 app . UseWeixinSite ( ) ;
128161
129162 app . UseRouting ( ) ;
0 commit comments