-
Notifications
You must be signed in to change notification settings - Fork 247
Wrong output order when mixing ConsoleLogger with System.Console #852
Comments
Your loop waits in each iteration of the loop, and hence is not parallel. Was that what you were aiming at? |
Yes, that is intentional. |
@muratg Just FYI--I frequently run into this issue as well. |
@pakrym any thoughts on this? |
It's the side effect of background logging in console logger that is done for performance reasons. We can add a flag to disable background logging, it would also solve the related issue with a requirement to dispose logger factory to get all console messages out. But mixing |
This is an important point IMHO. |
If the logger can flush all remaining messages synchronously, then this is an acceptable solution. The mixing comes from hosting inside a console application. The program itself doesn't know anything about logging or services, just creates an object and calls an entry point. Before and after, it writes some messages like "Press Ctrl+C to cancel" or "Press any key to exit". |
We periodically close 'discussion' issues that have not been updated in a long period of time. We apologize if this causes any inconvenience. We ask that if you are still encountering an issue, please log a new issue with updated information and we will investigate. |
When using the console logger, but also writing to the console using
System.Console.WriteLine
, the output doesn't match the order of calls:Output order at the end is non-deterministic, but after a few runs you will get something like this:
Using scopes does not solve the problem.
In my actual project, where the async methods do more stuff, and I have a few nested scopes, 100+ lines are shifted after the
System.Console.WriteLine
output.Tested with .NET Core 2.0 and 2.1.
The text was updated successfully, but these errors were encountered: