Running a Minecraft Forge server in windows has garbled logging output
I'm trying to set up a small personal Minecraft server off my Windows 10 computer. I tried running the server in both Powershell and Command Line (cmd), but they both yield output like this:
It's difficult to read and since the prompt character is [m, it makes it hard to read input commands as well.
For some reason, when I run the vanilla Minecraft server jar, the output is fine:
How can I fix it so I can run forge and have readable terminal output using nogui
?
Solution 1:
Minecraft Forge adds color-coded logging to the server output, to better distinguish different levels of warning. Unfortunately, it uses what's known as ANSI color escape sequences to do this, which some terminals don't support.
Luckily, Windows does support these (in theory, sometimes), but unluckily it's not obvious how to enable it, and there's no obvious option in the settings to do so.
With forge there is no (obvious, well documented) way to disable this behavior as a commandline flag, but you can at least fix it so Powershell displays the colors. There are several ways to deal with this, see this Stack Overflow answer for a full breakdown, but the easiest, least danger-prone method for fixing this is to change your Powershell server script to something like:
java -jar -Xmx8G -Xms512M -d64 .\forge-1.14.4-28.1.111.jar -nogui | Out-Host
This just pipes the output through a wrapper that recognizes the color encoding. You can also edit the registry to get this to permanently work, follow the linked answer above for more info. Do not do this if you're not comfortable using regedit, as there is the potential to mess up your Windows installation if done incorrectly. However, if you want to run a Forge server from the Command Prompt (cmd) instead of Powershell, you must do the registry method (to my knowledge), as cmd
does not support piping and Out-Host is a Powershell-specific construct.
Note that with the color coding enabled, if you interrupt the server in Powershell without letting it normally finish with stop
(e.g. you stop it with Ctrl+C), you'll find everything is colored the same way as the most recent log message. This is just because you interrupted the program before it could reset the color to your terminal color. It's not destructive, just restart Powershell and it will be back to normal.