7
7
using System . Net ;
8
8
using System . Threading ;
9
9
using System . Web . Http ;
10
+ using Microsoft . Azure . WebJobs . Logging ;
10
11
using Microsoft . Azure . WebJobs . Script . Config ;
11
12
using Microsoft . Azure . WebJobs . Script . Diagnostics ;
12
13
using Microsoft . Azure . WebJobs . Script . WebHost . Diagnostics ;
@@ -24,7 +25,6 @@ protected void Application_Start()
24
25
{
25
26
ServicePointManager . DefaultConnectionLimit = ScriptConstants . DynamicSkuConnectionLimit ;
26
27
}
27
-
28
28
ConfigureMinimumThreads ( settingsManager . IsDynamicSku ) ;
29
29
VerifyAndEnableShadowCopy ( webHostSettings ) ;
30
30
@@ -78,19 +78,28 @@ protected void Application_Error(object sender, EventArgs e)
78
78
EventGenerator eventGenerator = new EventGenerator ( ) ;
79
79
80
80
// Get the exception object.
81
- Exception exc = Server . GetLastError ( ) ;
81
+ Exception unhandledEx = Server . GetLastError ( ) ;
82
82
string subscriptionId = Utility . GetSubscriptionId ( ) ?? string . Empty ;
83
83
string appName = Utility . GetWebsiteUniqueSlotName ( ) ?? string . Empty ;
84
+ string exStackTrace = string . Empty ;
85
+ string exType = string . Empty ;
86
+ string exMessage = string . Empty ;
87
+ if ( unhandledEx != null )
88
+ {
89
+ exStackTrace = unhandledEx . StackTrace == null ? string . Empty : Sanitizer . Sanitize ( unhandledEx . ToFormattedString ( ) ) ;
90
+ exType = unhandledEx . GetType ( ) . ToString ( ) ;
91
+ exMessage = string . IsNullOrEmpty ( unhandledEx . Message ) ? string . Empty : unhandledEx . Message ;
92
+ }
84
93
eventGenerator . LogFunctionTraceEvent ( TraceLevel . Error ,
85
94
subscriptionId ,
86
95
appName ,
87
96
string . Empty ,
88
97
string . Empty ,
89
98
"Host.Startup" ,
90
- exc . StackTrace ,
99
+ exStackTrace ,
91
100
"Application start up failed." ,
92
- exc . GetType ( ) . ToString ( ) ,
93
- exc . Message ,
101
+ exType ,
102
+ exMessage ,
94
103
string . Empty ,
95
104
string . Empty ,
96
105
string . Empty ) ;
0 commit comments