You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Logs include control characters (in place of coloring) in Visual Studio output window when using Docker #673
changed the title [-]Logs include garbage characters in Visual Studio output window when using Docker[/-][+]Logs include garbage characters in place of coloring, in Visual Studio output window when using Docker[/+]on May 18, 2016
changed the title [-]Logs include garbage characters in place of coloring, in Visual Studio output window when using Docker[/-][+]Logs include control characters (in place of coloring) in Visual Studio output window when using Docker[/+]on May 18, 2016
@muratg Wouldn't it be better if VS would interpret the codes and display color output?
The WebPack Task Runner extension by @madskristensen, for example, supports color output in a VS pane:
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.
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.
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?
@muratg: We should really look at end-to-end scenarios to see how they can be improved. For the scenario mentioned above:
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.
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...
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?
Reacted by dagus, Zrean Tofiq, Gorbachev, Rushi Soni, realMarkusSchmidt, Todd Lucas, Clay Fowler, Martin Plante, Chris Burkhart, Zoran Mijatovic and 6 more
If you are using WebHostBuilder.CreateDefault setting ASPNETCORE_LOGGING__CONSOLE__DISABLECOLORS environment variable to true would disable colors too.
Activity
[-]Logs include garbage characters in Visual Studio output window when using Docker[/-][+]Logs include garbage characters in place of coloring, in Visual Studio output window when using Docker[/+][-]Logs include garbage characters in place of coloring, in Visual Studio output window when using Docker[/-][+]Logs include control characters (in place of coloring) in Visual Studio output window when using Docker[/+]muratg commentedon May 19, 2016
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?
nil4 commentedon May 19, 2016
@muratg Wouldn't it be better if VS would interpret the codes and display color output?

The WebPack Task Runner extension by @madskristensen, for example, supports color output in a VS pane:
muratg commentedon May 19, 2016
@nil4 Good point!
@BillHiebert Do you know if that's something we could do? AFAIK, npm console output has the same issue.
BillHiebert commentedon May 19, 2016
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.
glennc commentedon May 19, 2016
@SteveLasker Are the tools guys thinking about this already or were you expecting something from logging?
mikeharder commentedon May 19, 2016
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.
mikeharder commentedon May 19, 2016
It can be done from .NET via the
Console.IsOutputRedirectedproperty.mikeharder commentedon May 20, 2016
I ran a simple test and redirected the output to a file, and the file didn't contain any control characters:
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.
muratg commentedon May 26, 2016
Putting this in 1.0.1 milestone for further investigation post RTM.
mikeharder commentedon May 26, 2016
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.
mrgleba commentedon Jun 22, 2016
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?
muratg commentedon Jul 12, 2016
@mikeharder what's the current recommendation for this one?
cc @davidfowl
mikeharder commentedon Jul 12, 2016
@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.
BrennanConroy commentedon Jul 28, 2016
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...
BrennanConroy commentedon Jul 29, 2016
After some investigation we can't easily detect if the output is being redirected, see https://github.com/dotnet/corefx/issues/10428
neybar commentedon Nov 20, 2017
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?
mikeharder commentedon Jul 30, 2018
As a workaround, it's possible to use the
ConsoleLogger.DisableColorsoption added in 2.1: aspnet/Logging#772pakrym commentedon Nov 15, 2018
If you are using
WebHostBuilder.CreateDefaultsettingASPNETCORE_LOGGING__CONSOLE__DISABLECOLORSenvironment variable totruewould disable colors too.