New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logs include control characters (in place of coloring) in Visual Studio output window when using Docker #673
Comments
Not sure what's the proper way to fix this would be. Perhaps we can detect we're outputting to VS window and disable colors? |
@muratg Wouldn't it be better if VS would interpret the codes and display color output? |
@nil4 Good point! @BillHiebert Do you know if that's something we could do? AFAIK, npm console output has the same issue. |
The output window does not support colors today, nor does it recognize and strip the control characters from the text. There are some extensions you can install which do add colors but I don't know if they handle the control sequences. Failing that, Docker tooling needs to strip the characters from the strings before sending them on to the output window. |
@SteveLasker Are the tools guys thinking about this already or were you expecting something from logging? |
If possible, I think we should fix this at the Logging level, so any downstream consumer is fixed. I know some tools detect whether output is going to a console or redirected (to a file or another process), and change their output format accordingly. |
It can be done from .NET via the |
I ran a simple test and redirected the output to a file, and the file didn't contain any control characters: var factory = new LoggerFactory();
factory.AddConsole();
var logger = factory.CreateLogger<Program>();
logger.LogInformation("information");
So maybe Logging is already doing the right thing, and this does need to be fixed downstream. I will send mail to the Docker Tools for VS team. |
Putting this in 1.0.1 milestone for further investigation post RTM. |
The issue is most likely in Docker Tools for VS, rather than Logging. They have filed an issue on their end and will fix it when they are able. |
We're using this with Kestrel on mono inside docker. We're logging to the console and then we're using docker's syslog driver to forward the logs. As a result we get the string polluted by control characters. Maybe the simplest solution would be to include an option to disable colors altogether? |
@mikeharder what's the current recommendation for this one? cc @davidfowl |
@muratg: We should really look at end-to-end scenarios to see how they can be improved. For the scenario mentioned above:
One option might be logging to a file instead of the console. I've verified that control characters are not present when logging to a file. Another option might be for docker's driver to remove control characters. I think any process which writes colors to the console would have the same issue in Docker. Finally, we could add an option in Logging to disable colors, but this has a few drawbacks. First, the app author may not know when or whether to disable colors. It depends on the context the app is being used. Second, other tools like the CLI would also need to add options to disable colors. |
I'm not sure how you were even getting control characters on Windows since we don't write them unless you are on Unix. Unless our IsWindows check isn't working properly on Docker for Windows... |
After some investigation we can't easily detect if the output is being redirected, see https://github.com/dotnet/corefx/issues/10428 |
What is the status of this? We are using docker containers on AWS, and get the control characters in our logs. Makes it rather difficult to read. If it is difficult to auto detect, could we get an Environment variable or some other way to just turn off colorizing? |
As a workaround, it's possible to use the |
If you are using |
Repro Steps
Issue
Logs in output window include garbage characters in place of coloring:
CC: @glennc
The text was updated successfully, but these errors were encountered: