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,20 @@ public static class HostExtensions
1418{
1519 public static WebApplicationBuilder ConfigureServices ( this WebApplicationBuilder builder )
1620 {
21+ // Build a temporary logger for me.
22+ using var loggerFactory = LoggerFactory . Create ( logging =>
23+ {
24+ logging . AddConsole ( ) ;
25+ #if DEBUG
26+ logging . SetMinimumLevel ( LogLevel . Trace ) ;
27+ #else
28+ logging . SetMinimumLevel ( LogLevel . Information ) ;
29+ #endif
30+ } ) ;
31+ var logger = loggerFactory . CreateLogger < WebApplicationBuilder > ( ) ;
32+ logger . LogTrace ( $ "{ MethodBase . GetCurrentMethod ( ) . Name } ...") ;
33+ logger . LogDebug ( "Environment=" + builder . Environment . EnvironmentName ) ;
34+
1735 var Configuration = builder . Configuration ;
1836
1937 builder . Services . AddControllersWithViews ( ) ;
@@ -47,6 +65,10 @@ public static WebApplicationBuilder ConfigureServices(this WebApplicationBuilder
4765 o . AccessDeniedPath = "/Identity/Account/AccessDenied" ;
4866 } ) ;
4967
68+ logger ? . LogDebug ( "WeixinOpen:AppId=" + Configuration [ "WeixinOpen:AppId" ] ) ;
69+ logger ? . LogDebug ( "WeixinAuth:AppId=" + Configuration [ "WeixinAuth:AppId" ] ) ;
70+ logger ? . LogDebug ( "QQConnect:AppId=" + Configuration [ "QQConnect:AppId" ] ) ;
71+
5072 builder . Services . AddAuthentication ( )
5173 . AddWeixinOpen ( o =>
5274 {
@@ -74,6 +96,8 @@ public static WebApplicationBuilder ConfigureServices(this WebApplicationBuilder
7496 QQConnectScopes . do_like ) ;
7597 } ) ;
7698
99+ logger ? . LogDebug ( "TencensSms:SdkAppId=" + Configuration [ "TencentSms:SdkAppId" ] ) ;
100+
77101 builder . Services . AddTencentSms ( o =>
78102 {
79103 o . SdkAppId = Configuration [ "TencentSms:SdkAppId" ] ;
@@ -82,6 +106,8 @@ public static WebApplicationBuilder ConfigureServices(this WebApplicationBuilder
82106
83107 builder . Services . AddViewDivert ( ) ;
84108
109+ logger ? . LogDebug ( "Weixin:AppId=" + Configuration [ "Weixin:AppId" ] ) ;
110+
85111 builder . Services . AddWeixin ( o =>
86112 {
87113 o . AppId = Configuration [ "Weixin:AppId" ] ;
@@ -111,6 +137,10 @@ public static WebApplicationBuilder ConfigureServices(this WebApplicationBuilder
111137
112138 public static WebApplication ConfigurePipeline ( this WebApplication app )
113139 {
140+ var logger = app . Logger ;
141+ logger . LogTrace ( $ "{ MethodBase . GetCurrentMethod ( ) . Name } ...") ;
142+ logger . LogDebug ( $ "Environment={ app . Environment . EnvironmentName } ") ;
143+
114144 var env = app . Environment ;
115145 if ( env . IsDevelopment ( ) )
116146 {
@@ -124,6 +154,8 @@ public static WebApplication ConfigurePipeline(this WebApplication app)
124154 }
125155 //app.UseHttpsRedirection();
126156 app . UseStaticFiles ( ) ;
157+
158+ logger . LogTrace ( "UseWeixinSite..." ) ;
127159 app . UseWeixinSite ( ) ;
128160
129161 app . UseRouting ( ) ;
0 commit comments