diff --git a/src/Dapr.Workflow/WorkflowLoggingService.cs b/src/Dapr.Workflow/WorkflowLoggingService.cs index 5297612c1..482d95b97 100644 --- a/src/Dapr.Workflow/WorkflowLoggingService.cs +++ b/src/Dapr.Workflow/WorkflowLoggingService.cs @@ -39,17 +39,17 @@ public Task StartAsync(CancellationToken cancellationToken) { this.logger.Log(LogLevel.Information, "WorkflowLoggingService started"); - this.logger.Log(LogLevel.Information, "List of registered workflows"); - foreach (string item in registeredWorkflows) - { - this.logger.Log(LogLevel.Information, item); - } + this.logger.Log(LogLevel.Information, "List of registered workflows"); + foreach (string item in registeredWorkflows) + { + this.logger.Log(LogLevel.Information, item); + } - this.logger.Log(LogLevel.Information, "List of registered activities:"); - foreach (string item in registeredActivities) - { - this.logger.Log(LogLevel.Information, item); - } + this.logger.Log(LogLevel.Information, "List of registered activities:"); + foreach (string item in registeredActivities) + { + this.logger.Log(LogLevel.Information, item); + } return Task.CompletedTask; } diff --git a/test/Dapr.E2E.Test.App/Program.cs b/test/Dapr.E2E.Test.App/Program.cs index 8e510d00f..5713129d5 100644 --- a/test/Dapr.E2E.Test.App/Program.cs +++ b/test/Dapr.E2E.Test.App/Program.cs @@ -19,6 +19,7 @@ public class Program { public static void Main(string[] args) { + Log.Logger = new LoggerConfiguration().WriteTo.File("log.txt").CreateLogger(); CreateHostBuilder(args).Build().Run(); } diff --git a/test/Dapr.E2E.Test/Workflows/WorkflowTest.cs b/test/Dapr.E2E.Test/Workflows/WorkflowTest.cs index 0badf67e9..b996e49d1 100644 --- a/test/Dapr.E2E.Test/Workflows/WorkflowTest.cs +++ b/test/Dapr.E2E.Test/Workflows/WorkflowTest.cs @@ -43,13 +43,12 @@ public async Task TestWorkflowLogging() var health = await daprClient.CheckHealthAsync(); health.Should().Be(true, "DaprClient is not healthy"); - var searchTask = Task.Run(() => + var searchTask = Task.Run(async() => { using (StreamReader reader = new StreamReader(logFilePath)) { string line; - - while ((line = reader.ReadLine()) != null) + while ((line = await reader.ReadLineAsync()) != null) { foreach (var entry in logStrings) { @@ -67,12 +66,18 @@ public async Task TestWorkflowLogging() } }, cts.Token); - if (!Task.WaitAll(new Task[] {searchTask}, timeout)) + try + { + await searchTask; + } + finally { File.Delete(logFilePath); - Assert.True(false, "Expected logs weren't found within timeout period"); + if (!allLogsFound) + { + Assert.True(false, "The logs were not able to found within the timeout"); + } } - File.Delete(logFilePath); } [Fact] public async Task TestWorkflows()