@@ -388,7 +388,9 @@ private async Task<ExecutionInfo> ExecHandlerAsync(string handler, string dataIn
388388 var userCodeLoader = new UserCodeLoader ( new SystemEnvironmentVariables ( ) , handler , _internalLogger ) ;
389389 var handlerWrapper = HandlerWrapper . GetHandlerWrapper ( userCodeLoader . Invoke ) ;
390390 var initializer = new UserCodeInitializer ( userCodeLoader , _internalLogger ) ;
391- var bootstrap = new LambdaBootstrap ( handlerWrapper . Handler , initializer . InitializeAsync , null , _environmentVariables )
391+ // Pass null initializer to bootstrap so RunAsync won't re-invoke Init(),
392+ // which would re-register AssemblyLoad event handlers and re-construct the invoke delegate.
393+ var bootstrap = new LambdaBootstrap ( handlerWrapper . Handler , null , null , _environmentVariables )
392394 {
393395 Client = testRuntimeApiClient
394396 } ;
@@ -403,7 +405,13 @@ private async Task<ExecutionInfo> ExecHandlerAsync(string handler, string dataIn
403405 Assert . DoesNotContain ( $ "^^[{ assertLoggedByInitialize } ]^^", actionWriter . ToString ( ) ) ;
404406 }
405407
406- await bootstrap . InitializeAsync ( ) ;
408+ await initializer . InitializeAsync ( ) ;
409+
410+ // Re-set logging actions after initialization in case Init's AssemblyLoad event
411+ // handler overwrote them when loading Amazon.Lambda.Core as a handler dependency.
412+ UserCodeLoader . SetCustomerLoggerLogAction ( assembly , actionWriter . ToLoggingAction ( ) , _internalLogger ) ;
413+ UserCodeLoader . SetCustomerLoggerLogAction ( assembly , actionWriter . ToLoggingWithLevelAction ( ) , _internalLogger ) ;
414+ UserCodeLoader . SetCustomerLoggerLogAction ( assembly , actionWriter . ToLoggingWithLevelAndExceptionAction ( ) , _internalLogger ) ;
407415
408416 if ( assertLoggedByInitialize != null )
409417 {
0 commit comments