Skip to content

Commit 17e5be6

Browse files
shirhattijkotalik
authored andcommitted
Clean up event log strings for ANCM (#4515)
1 parent 237a7a6 commit 17e5be6

File tree

9 files changed

+146
-45
lines changed

9 files changed

+146
-45
lines changed

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/EventLog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ EventLog::LogEventNoTrace(
2121
}
2222
// Static locals to avoid getting the process ID and string multiple times.
2323
// Effectively have the same semantics as global variables, except initialized
24-
// on first occurence.
24+
// on first occurrence.
2525
static const auto processIdString = GetProcessIdString();
2626
static const auto versionInfoString = GetVersionInfoString();
2727

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/aspnetcore_msg.mc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Language=English
6363
.
6464
6565
Messageid=1007
66-
SymbolicName=ASPNETCORE_EVENT_LOAD_CLR_FALIURE
66+
SymbolicName=ASPNETCORE_EVENT_LOAD_CLR_FAILURE
6767
Language=English
6868
%1
6969
.

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/resources.h

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,36 @@
1414
#define ASPNETCORE_EVENT_PROCESS_START_SUCCESS_MSG L"Application '%s' started process '%d' successfully and process '%d' is listening on port '%d'."
1515
#define ASPNETCORE_EVENT_RAPID_FAIL_COUNT_EXCEEDED_MSG L"Maximum rapid fail count per minute of '%d' exceeded."
1616
#define ASPNETCORE_EVENT_PROCESS_START_ERROR_MSG L"Application '%s' with physical root '%s' failed to start process with commandline '%s' at stage '%s', ErrorCode = '0x%x', assigned port %d, retryCounter '%d'."
17-
#define ASPNETCORE_EVENT_PROCESS_START_FAILURE_MSG L"Application '%s' with physical root '%s' failed to start process with commandline '%s' with multiple retries. The last try of listening port is '%d'. See previous warnings for details."
18-
#define ASPNETCORE_EVENT_PROCESS_START_STATUS_ERROR_MSG L"Application '%s' with physical root '%s' failed to start process with commandline '%s' , ErrorCode = '0x%x', processId '%d', processStatus '%d'."
17+
#define ASPNETCORE_EVENT_PROCESS_START_FAILURE_MSG L"Application '%s' with physical root '%s' failed to start process with commandline '%s' with multiple retries. Failed to bind to port '%d'. See previous warnings for details."
18+
#define ASPNETCORE_EVENT_PROCESS_START_STATUS_ERROR_MSG L"Application '%s' with physical root '%s' failed to start process with commandline '%s', ErrorCode = '0x%x', processId '%d', processStatus '%d'."
1919
#define ASPNETCORE_EVENT_PROCESS_START_PORTSETUP_ERROR_MSG L"Application '%s' with physical root '%s' failed to choose listen port '%d' given port range '%d - %d', ErrorCode = '0x%x'. If environment variable 'ASPNETCORE_PORT' was set, try removing it such that a random port is selected instead."
2020
#define ASPNETCORE_EVENT_PROCESS_START_WRONGPORT_ERROR_MSG L"Application '%s' with physical root '%s' created process with commandline '%s' but failed to listen on the given port '%d'"
21-
#define ASPNETCORE_EVENT_PROCESS_START_NOTREADY_ERROR_MSG L"Application '%s' with physical root '%s' created process with commandline '%s' but either crashed or did not respond or did not listen on the given port '%d', ErrorCode = '0x%x'"
21+
#define ASPNETCORE_EVENT_PROCESS_START_NOTREADY_ERROR_MSG L"Application '%s' with physical root '%s' created process with commandline '%s' but either crashed, did not respond, or did not listen on the given port '%d', ErrorCode = '0x%x'"
2222
#define ASPNETCORE_EVENT_PROCESS_SHUTDOWN_MSG L"Application '%s' with physical root '%s' shut down process with Id '%d' listening on port '%d'"
23-
#define ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG L"Warning: Could not create stdoutLogFile %s, ErrorCode = '0x%x'."
24-
#define ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE_MSG L"Failed to gracefully shutdown process '%d'."
25-
#define ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST_MSG L"Sent shutdown HTTP message to process '%d' and received http status '%d'."
23+
#define ASPNETCORE_EVENT_INVALID_STDOUT_LOG_FILE_MSG L"Could not create stdoutLogFile %s, ErrorCode = '0x%x'."
24+
#define ASPNETCORE_EVENT_GRACEFUL_SHUTDOWN_FAILURE_MSG L"Failed to gracefully shutdown process with Id '%d'."
25+
#define ASPNETCORE_EVENT_SENT_SHUTDOWN_HTTP_REQUEST_MSG L"Sent shutdown HTTP message to process with Id '%d' and received http status '%d'."
2626
#define ASPNETCORE_EVENT_APP_SHUTDOWN_FAILURE_MSG L"Failed to gracefully shutdown application '%s'."
27-
#define ASPNETCORE_EVENT_LOAD_CLR_FALIURE_MSG L"Application '%s' with physical root '%s' failed to load clr and managed application. %s"
27+
#define ASPNETCORE_EVENT_LOAD_CLR_FAILURE_MSG L"Application '%s' with physical root '%s' failed to load coreclr. Exception message:\r\n%s"
2828
#define ASPNETCORE_EVENT_APP_SHUTDOWN_SUCCESSFUL_MSG L"Application '%s' has shutdown."
29-
#define ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP_MSG L"Only one inprocess application is allowed per IIS application pool. Please assign the application '%s' to a different IIS application pool."
29+
#define ASPNETCORE_EVENT_DUPLICATED_INPROCESS_APP_MSG L"Only one in-process application is allowed per IIS application pool. Please assign the application '%s' to a different IIS application pool."
3030
#define ASPNETCORE_EVENT_MIXED_HOSTING_MODEL_ERROR_MSG L"Mixed hosting model is not supported. Application '%s' configured with different hostingModel value '%d' other than the one of running application(s)."
31-
#define ASPNETCORE_CONFIGURATION_LOAD_ERROR_MSG L"Could not load configuration. Exception message: %s"
31+
#define ASPNETCORE_CONFIGURATION_LOAD_ERROR_MSG L"Could not load configuration. Exception message:\r\n%s"
3232
#define ASPNETCORE_EVENT_ADD_APPLICATION_ERROR_MSG L"Failed to start application '%s', ErrorCode '0x%x'."
33-
#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_STDOUT_MSG L"Application '%s' with physical root '%s' hit unexpected managed background thread exit, exit code = '%d'. Last 4KB characters of captured stdout and stderr logs:\r\n%s"
34-
#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_MSG L"Application '%s' with physical root '%s' hit unexpected managed background thread exit, exit code = '%d'. Please check the stderr logs for more information."
35-
#define ASPNETCORE_EVENT_APP_IN_SHUTDOWN_MSG L"Application shutting down."
36-
#define ASPNETCORE_EVENT_RECYCLE_APPOFFLINE_MSG L"Application '%s' was recycled after detecting the app_offline file."
37-
#define ASPNETCORE_EVENT_MONITOR_APPOFFLINE_ERROR_MSG L"Monitoring app_offline.htm failed for application '%s', ErrorCode '0x%x'. "
33+
#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_STDOUT_MSG L"Application '%s' with physical root '%s' has exited from Program.Main with exit code = '%d'. Last 30KB characters of captured stdout and stderr logs:\r\n%s"
34+
#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXIT_MSG L"Application '%s' with physical root '%s' has exited from Program.Main with exit code = '%d'. Please check the stderr logs for more information."
35+
#define ASPNETCORE_EVENT_RECYCLE_APPOFFLINE_MSG L"Application '%s' was recycled after detecting app_offline.htm."
36+
#define ASPNETCORE_EVENT_MONITOR_APPOFFLINE_ERROR_MSG L"Failed to monitor app_offline.htm for application '%s', ErrorCode '0x%x'. "
3837
#define ASPNETCORE_EVENT_RECYCLE_CONFIGURATION_MSG L"Application '%s' was recycled due to configuration change"
39-
#define ASPNETCORE_EVENT_RECYCLE_FAILURE_CONFIGURATION_MSG L"Failed to recycle application due to a configuration change at '%s'. Recycling worker process."
38+
#define ASPNETCORE_EVENT_RECYCLE_FAILURE_CONFIGURATION_MSG L"Failed to recycle application after a configuration change at '%s'. Recycling worker process."
4039
#define ASPNETCORE_EVENT_MODULE_DISABLED_MSG L"AspNetCore Module is disabled"
4140
#define ASPNETCORE_EVENT_HOSTFXR_DLL_INVALID_VERSION_MSG L"Hostfxr version used does not support 'hostfxr_get_native_search_directories', update the version of hostfxr to a higher version. Path to hostfxr: '%s'."
4241
#define ASPNETCORE_EVENT_HOSTFXR_DLL_UNABLE_TO_LOAD_MSG L"Unable to load '%s'. This might be caused by a bitness mismatch between IIS application pool and published application."
43-
#define ASPNETCORE_EVENT_HOSTFXR_FAILURE_MSG L"Invoking hostfxr to find the inprocess request handler failed without finding any native dependencies. This most likely means the app is misconfigured, please check the versions of Microsoft.NetCore.App and Microsoft.AspNetCore.App that are targeted by the application and are installed on the machine."
42+
#define ASPNETCORE_EVENT_HOSTFXR_FAILURE_MSG L"Unable to locate application dependencies. Ensure that the versions of Microsoft.NetCore.App and Microsoft.AspNetCore.App targeted by the application are installed."
4443
#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXCEPTION_MSG L"Application '%s' with physical root '%s' hit unexpected managed exception, exception code = '0x%x'. Please check the stderr logs for more information."
45-
#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXCEPTION_STDOUT_MSG L"Application '%s' with physical root '%s' hit unexpected managed exception, exception code = '0x%x'. Last 4KB characters of captured stdout and stderr logs:\r\n%s"
46-
#define ASPNETCORE_EVENT_INPROCESS_RH_ERROR_MSG L"Could not find inprocess request handler. Captured output from invoking hostfxr: %s"
44+
#define ASPNETCORE_EVENT_INPROCESS_THREAD_EXCEPTION_STDOUT_MSG L"Application '%s' with physical root '%s' hit unexpected managed exception, exception code = '0x%x'. Last 30KB characters of captured stdout and stderr logs:\r\n%s"
45+
#define ASPNETCORE_EVENT_INPROCESS_RH_ERROR_MSG L"Could not find 'aspnetcorev2_inprocess.dll'. Exception message:\r\n%s"
4746
#define ASPNETCORE_EVENT_INPROCESS_RH_REFERENCE_MSG L"Could not find the assembly '%s' referenced for the in-process application. Please confirm the Microsoft.AspNetCore.Server.IIS package is referenced in your application."
4847
#define ASPNETCORE_EVENT_OUT_OF_PROCESS_RH_MISSING_MSG L"Could not find the assembly '%s' for out-of-process application. Please confirm the assembly is installed correctly for IIS or IISExpress."
49-
#define ASPNETCORE_EVENT_INPROCESS_START_SUCCESS_MSG L"Application '%s' started the coreclr in-process successfully."
50-
#define ASPNETCORE_EVENT_INPROCESS_START_ERROR_MSG L"Application '%s' wasn't able to start. %s"
48+
#define ASPNETCORE_EVENT_INPROCESS_START_SUCCESS_MSG L"Application '%s' started successfully."
49+
#define ASPNETCORE_EVENT_INPROCESS_START_ERROR_MSG L"Application '%s' failed to start. Exception message:\r\n%s"

src/Servers/IIS/AspNetCoreModuleV2/InProcessRequestHandler/inprocessapplication.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ IN_PROCESS_APPLICATION::ExecuteApplication()
303303
catch (InvalidOperationException& ex)
304304
{
305305
EventLog::Error(
306-
ASPNETCORE_EVENT_LOAD_CLR_FALIURE,
307-
ASPNETCORE_EVENT_LOAD_CLR_FALIURE_MSG,
306+
ASPNETCORE_EVENT_LOAD_CLR_FAILURE,
307+
ASPNETCORE_EVENT_LOAD_CLR_FAILURE_MSG,
308308
QueryApplicationId().c_str(),
309309
QueryApplicationPhysicalPath().c_str(),
310310
ex.as_wstring().c_str());
@@ -314,8 +314,8 @@ IN_PROCESS_APPLICATION::ExecuteApplication()
314314
catch (std::runtime_error& ex)
315315
{
316316
EventLog::Error(
317-
ASPNETCORE_EVENT_LOAD_CLR_FALIURE,
318-
ASPNETCORE_EVENT_LOAD_CLR_FALIURE_MSG,
317+
ASPNETCORE_EVENT_LOAD_CLR_FAILURE,
318+
ASPNETCORE_EVENT_LOAD_CLR_FAILURE_MSG,
319319
QueryApplicationId().c_str(),
320320
QueryApplicationPhysicalPath().c_str(),
321321
GetUnexpectedExceptionMessage(ex).c_str());
@@ -363,8 +363,8 @@ HRESULT IN_PROCESS_APPLICATION::Start(
363363
catch (InvalidOperationException& ex)
364364
{
365365
EventLog::Error(
366-
ASPNETCORE_EVENT_LOAD_CLR_FALIURE,
367-
ASPNETCORE_EVENT_LOAD_CLR_FALIURE_MSG,
366+
ASPNETCORE_EVENT_LOAD_CLR_FAILURE,
367+
ASPNETCORE_EVENT_LOAD_CLR_FAILURE_MSG,
368368
pHttpApplication.GetApplicationId(),
369369
pHttpApplication.GetApplicationPhysicalPath(),
370370
ex.as_wstring().c_str());
@@ -374,8 +374,8 @@ HRESULT IN_PROCESS_APPLICATION::Start(
374374
catch (std::runtime_error& ex)
375375
{
376376
EventLog::Error(
377-
ASPNETCORE_EVENT_LOAD_CLR_FALIURE,
378-
ASPNETCORE_EVENT_LOAD_CLR_FALIURE_MSG,
377+
ASPNETCORE_EVENT_LOAD_CLR_FAILURE,
378+
ASPNETCORE_EVENT_LOAD_CLR_FAILURE_MSG,
379379
pHttpApplication.GetApplicationId(),
380380
pHttpApplication.GetApplicationPhysicalPath(),
381381
GetUnexpectedExceptionMessage(ex).c_str());

src/Servers/IIS/IIS/test/Common.FunctionalTests/ConfigurationChangeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public async Task OutOfProcessToInProcessHostingModelSwitchWorks()
8383
await deploymentResult.HttpClient.RetryRequestAsync("/HelloWorld", r => r.StatusCode == HttpStatusCode.InternalServerError);
8484

8585
StopServer();
86-
EventLogHelpers.VerifyEventLogEvent(deploymentResult, "Could not find the assembly 'aspnetcorev2_inprocess.dll'", Logger);
86+
EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.CouldNotFindHandler(), Logger);
8787
}
8888

8989
[ConditionalTheory]

src/Servers/IIS/IIS/test/Common.FunctionalTests/Inprocess/EventLogTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public async Task CheckStartupEventLogMessage()
2828

2929
StopServer();
3030

31-
EventLogHelpers.VerifyEventLogEvent(deploymentResult, "Application '.+' started the coreclr in-process successfully.");
31+
EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessStarted(deploymentResult));
3232
}
3333

3434
[ConditionalFact]

src/Servers/IIS/IIS/test/Common.FunctionalTests/Inprocess/StartupTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public async Task InvalidProcessPath_ExpectServerError(string path, string argum
6161

6262
StopServer();
6363

64-
EventLogHelpers.VerifyEventLogEvent(deploymentResult, $@"Application '{Regex.Escape(deploymentResult.ContentRoot)}\\' wasn't able to start. {subError}");
64+
EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.UnableToStart(deploymentResult, subError));
6565

6666
Assert.Contains("HTTP Error 500.0 - ANCM In-Process Handler Load Failure", await response.Content.ReadAsStringAsync());
6767
}

src/Servers/IIS/IIS/test/Common.FunctionalTests/MultiApplicationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public async Task FailsAndLogsWhenRunningTwoInProcessApps()
5151
Assert.Equal(200, (int)result1.StatusCode);
5252
Assert.Equal(500, (int)result2.StatusCode);
5353
StopServer();
54-
EventLogHelpers.VerifyEventLogEvent(result, "Only one inprocess application is allowed per IIS application pool");
54+
EventLogHelpers.VerifyEventLogEvent(result, EventLogHelpers.OnlyOneAppPerAppPool());
5555
}
5656

5757
[ConditionalTheory]

0 commit comments

Comments
 (0)