Adding New Line in Docker Log Console when the Message is too long

I have a .Net Core 3.1 WepAPI running in a Docker Container Debian GNU/Linux 10 (buster). I am sending from the Application Logs to the console. When I run the WebApi in my local environment, everything works fine but when I run it in the container, it is adding New lines in the messages when it is too long.

There is a reason why this is happening

Thank you

Please, tell us more about your issue. What is “too long”? How long? Where is that new line? In the output of docker logs?

Note that the size of the terminal inside a container can be different than on your host. If you run docker exec to start the app that sends logs to the console, you can get additional linebreaks. You can make it larger this way:

docker exec -it -e COLUMNS="$(tput cols)" CONTAINER_NAME bash

but this should not affect the output of docker logs.

When the message is too long and is sent to be printed out to the console, a new line is added to the message.

Please, try to answer my questions. Without that I can’t help you. You have already written that the message is “too long”. I have no idea what that means and I have no idea how you run the command and which console you mean exactly…

Right now I am running the Docker using VS 2019.

I put some img’s where in the Output of VS the logs Msg is just one line

But when I copy the messages from the Logs in docker Desktop, they have new lines

I can be related to Visual Studio and Windows, since Windows has different line ending characters. Windows uses “CR+LF”. This is what you can see on the second screenshot. If you are running Linux containers on a Debian Linux, those containers should use just LF. Sometimes when you copy something from Windows to Linux you get extra lines, because Linux handles CR differently. Editors usually show extra lines, copying CR into a bash script can make that script unsuable. If you are running Linux containers using the WSL backend, try enable WSL integration on Docker Desktop and log in to the WSL distribution, run docker logs and redirect the output into a file like this:

docker logs CONTAINER_NAME &> log.txt

Then copy that file out and check the file in an editor. If that works, than the problem was Visual Studio.