This repository was archived by the owner on Aug 29, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -66,9 +66,9 @@ static async Task<int> Main(string[] args)
6666
6767 builder . AddMiddleware ( async ( ic , next ) =>
6868 {
69- var op = ic . GetHost ( ) . Services . GetService < IOptions < ExtraOptions > > ( ) ;
69+ var op = ic . GetHost ( ) . Services . GetService < IOptions < ExtraOptions > > ( ) ? . Value ;
7070 // Show Azure Identity logs if the --debug option is set
71- using AzureEventSourceListener ? listener = AzureEventSourceListener . CreateConsoleLogger ( op ? . Value ? . DebugEnabled == true ? EventLevel . LogAlways : EventLevel . Warning ) ;
71+ using AzureEventSourceListener ? listener = op ? . DebugEnabled == true ? AzureEventSourceListener . CreateConsoleLogger ( EventLevel . LogAlways ) : null ;
7272 await next ( ic ) ;
7373 } ) ;
7474 builder . AddMiddleware ( async ( ic , next ) =>
@@ -201,8 +201,9 @@ static IHostBuilder CreateHostBuilder(string[] args) =>
201201 {
202202 logBuilder . SetMinimumLevel ( LogLevel . Warning ) ;
203203 // If a config is unavailable, troubleshoot using (ctx.Configuration as IConfigurationRoot)?.GetDebugView();
204- var options = ctx . GetInvocationContext ( ) . BindingContext . GetService < IOptions < ExtraOptions > > ( ) ? . Value ;
205- if ( options ? . DebugEnabled == true )
204+ // At this point, the host isn't ready. Get the config option directly.
205+ var debugEnabled = ctx . Configuration . GetValue < bool > ( "Debug" ) ;
206+ if ( debugEnabled == true )
206207 {
207208 logBuilder . AddFilter ( "Microsoft.Graph.Cli" , LogLevel . Debug ) ;
208209 }
You can’t perform that action at this time.
0 commit comments