11using CoreAppUAP . Common ;
22using CoreAppUAP . Helpers ;
33using CoreAppUAP . Pages ;
4+ using Microsoft . Extensions . Logging ;
45using System ;
56using System . Threading ;
67using Windows . ApplicationModel ;
@@ -141,7 +142,7 @@ private static void EnsureWindow(IActivatedEventArgs e)
141142 }
142143 catch ( Exception ex )
143144 {
144- SettingsHelper . LogManager . GetLogger ( nameof ( App ) ) . Error ( ex . ExceptionToMessage ( ) , ex ) ;
145+ SettingsHelper . LoggerFactory . CreateLogger < App > ( ) . LogError ( "Failed to set CoreApplication.EnablePrelaunch(true). {message} (0x{hResult:X})" , ex . GetMessage ( ) , ex . HResult ) ;
145146 goto end ;
146147 }
147148 }
@@ -185,15 +186,18 @@ private static void OnSuspending(object sender, SuspendingEventArgs e)
185186
186187 private static void Application_UnhandledException ( object sender , Windows . UI . Xaml . UnhandledExceptionEventArgs e )
187188 {
188- SettingsHelper . LogManager ? . GetLogger ( "Unhandled Exception - Application" ) . Error ( e . Exception . ExceptionToMessage ( ) , e . Exception ) ;
189+ if ( e . Exception is Exception ex )
190+ {
191+ SettingsHelper . LoggerFactory . CreateLogger ( "Unhandled Exception - Application" ) . LogError ( ex , "Unhandled exception. {message} (0x{hResult:X})" , ex . GetMessage ( ) , ex . HResult ) ;
192+ }
189193 e . Handled = true ;
190194 }
191195
192196 private static void CurrentDomain_UnhandledException ( object sender , System . UnhandledExceptionEventArgs e )
193197 {
194198 if ( e . ExceptionObject is Exception ex )
195199 {
196- SettingsHelper . LogManager ? . GetLogger ( "Unhandled Exception - CurrentDomain" ) . Error ( ex . ExceptionToMessage ( ) , ex ) ;
200+ SettingsHelper . LoggerFactory . CreateLogger ( "Unhandled Exception - CurrentDomain" ) . LogError ( ex , "Unhandled exception. {message} (0x{hResult:X})" , ex . GetMessage ( ) , ex . HResult ) ;
197201 }
198202 }
199203
@@ -210,7 +214,10 @@ private static void RegisterExceptionHandlingSynchronizationContext()
210214
211215 private static void SynchronizationContext_UnhandledException ( object sender , Common . UnhandledExceptionEventArgs e )
212216 {
213- SettingsHelper . LogManager ? . GetLogger ( "Unhandled Exception - SynchronizationContext" ) . Error ( e . Exception . ExceptionToMessage ( ) , e . Exception ) ;
217+ if ( e . Exception is Exception ex )
218+ {
219+ SettingsHelper . LoggerFactory . CreateLogger ( "Unhandled Exception - SynchronizationContext" ) . LogError ( ex , "Unhandled exception. {message} (0x{hResult:X})" , ex . GetMessage ( ) , ex . HResult ) ;
220+ }
214221 e . Handled = true ;
215222 }
216223 }
0 commit comments