diff --git a/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/Directory.Build.targets.template b/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/Directory.Build.targets.template
new file mode 100644
index 0000000000..8c119d5413
--- /dev/null
+++ b/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/Directory.Build.targets.template
@@ -0,0 +1,2 @@
+
+
diff --git a/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/LoggingInterceptor.cs b/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/LoggingInterceptor.cs
index 7d05212d50..1d7d8fcafb 100644
--- a/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/LoggingInterceptor.cs
+++ b/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/LoggingInterceptor.cs
@@ -11,31 +11,31 @@ namespace Microsoft.AspNetCore.AzureAppServices.FunctionalTests
{
public class LoggingInterceptor : IServiceClientTracingInterceptor
{
- private readonly ILogger _logger;
+ private readonly ILogger _globalLogger;
- public LoggingInterceptor(ILogger logger)
+ public LoggingInterceptor(ILogger globalLogger)
{
- _logger = logger;
+ _globalLogger = globalLogger;
}
public void Information(string message)
{
- _logger.LogInformation(message);
+ CurrentLogger.LogInformation(message);
}
public void TraceError(string invocationId, Exception exception)
{
- _logger.LogInformation(exception, "Exception in {invocationId}", invocationId);
+ CurrentLogger.LogInformation(exception, "Exception in {invocationId}", invocationId);
}
public void ReceiveResponse(string invocationId, HttpResponseMessage response)
{
- _logger.LogInformation(response.AsFormattedString());
+ CurrentLogger.LogInformation(response.AsFormattedString());
}
public void SendRequest(string invocationId, HttpRequestMessage request)
{
- _logger.LogInformation(request.AsFormattedString());
+ CurrentLogger.LogInformation(request.AsFormattedString());
}
public void Configuration(string source, string name, string value) { }
@@ -43,5 +43,7 @@ namespace Microsoft.AspNetCore.AzureAppServices.FunctionalTests
public void EnterMethod(string invocationId, object instance, string method, IDictionary parameters) { }
public void ExitMethod(string invocationId, object returnValue) { }
+
+ private ILogger CurrentLogger => TestLogger.Current ?? _globalLogger;
}
}
\ No newline at end of file
diff --git a/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/Microsoft.AspNetCore.AzureAppServices.FunctionalTests.csproj b/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/Microsoft.AspNetCore.AzureAppServices.FunctionalTests.csproj
index 0da59f8f4e..1ae218e17d 100644
--- a/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/Microsoft.AspNetCore.AzureAppServices.FunctionalTests.csproj
+++ b/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/Microsoft.AspNetCore.AzureAppServices.FunctionalTests.csproj
@@ -10,6 +10,7 @@
+
diff --git a/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/TestLogger.cs b/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/TestLogger.cs
index 0c03a48e2e..ad02ce1563 100644
--- a/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/TestLogger.cs
+++ b/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/TestLogger.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
+using System.Threading;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.AzureAppServices.FunctionalTests
@@ -12,8 +13,13 @@ namespace Microsoft.AspNetCore.AzureAppServices.FunctionalTests
private readonly ILogger _logger;
+ private static readonly AsyncLocal _currentLogger = new AsyncLocal();
+
+ public static TestLogger Current => _currentLogger.Value;
+
public TestLogger(ILoggerFactory factory, ILogger logger)
{
+ _currentLogger.Value = this;
_factory = factory;
_logger = logger;
}
@@ -35,6 +41,7 @@ namespace Microsoft.AspNetCore.AzureAppServices.FunctionalTests
public void Dispose()
{
+ _currentLogger.Value = null;
_factory.Dispose();
}
}