TerminalConsoleAppender
TerminalConsoleAppender copied to clipboard
Colors not working
Hi, i am trying to use that library on my standalone project. However Minecraft Formatting (i know it is deprecated, but i want to use it) is not working as expected
- Not working in intellij, while log4j's highlight colors are working perfectly, and it works if i use the override property
- I am getting a weird character in the place of the color code, even if colors aren't even applied:

Am i doing something incorrectly?
Am i doing something incorrectly?
I don't know, you didn't post any of your configuration or code so I could just make bad guesses. :/
https://github.com/BlueTree242/PreBot/blob/f8f23fd9e2aa9277abbee87b788c2b85fa16ae35/launcher/src/main/resources/log4j2.xml this is my log4j2.xml
So does it only not work in IntelliJ?
it works in windows terminal, and in intellij if i use override property, and im getting that weird character in both cases
For the IntelliJ detection: It's complicated to get it right, I think the detection might not work correctly at the moment if you run using the Gradle task in IntelliJ. (It should work when using the normal IntelliJ run configurations.)
That char looks like you put more than §c in the string. I'd say the color (§c?) is applied correctly but there is some garbage before it.
yup, i wanna remove the garbage
For the IntelliJ detection: It's complicated to get it right, I think the detection might not work correctly at the moment if you run using the Gradle task in IntelliJ. (It should work when using the normal IntelliJ run configurations.)
That char looks like you put more than
§cin the string. I'd say the color (§c?) is applied correctly but there is some garbage before it.
Well i only put a color code, even if i did multiple... It shouldn't act like that right?
If you'd do e.g. §§c it would likely produce something like this, since the converter only touches valid color codes.
(Although maybe one would expect the terminal to display § and not this garbage...)
im sure i didn't do that, ive wrote the color code 5 separate times i never saw extra §
Uh, the garbage is always only at the beginning of the line?
no, i tried putting the color code in middle and the garbage was in middle too
I'd suggest removing the {strip} from the %minecraftFormatting in the RollingRandomAccessFile output, and then look at the log file with a proper editor to find out what kind of char this really is (the "?" doesn't tell much).
good idea, ill try
i see this when i open logs in intellij
Open it in a different editor? Perhaps even in a hex editor if necessary.
i tried visual studio code, and i got the same thing, i tried notepad and i got this:
i don't have any more editors, do you suggest any others
Looks like there is a Hex Editor extension for vscode that would allow you to see the numeric value of that char: https://marketplace.visualstudio.com/items?itemName=ms-vscode.hexeditor (no idea how to use it)
ok. using hex editor, i got 3 dots in location of garbage, this is when clicking each in order:

OK very strange, not sure where that'd come from. If you want you can upload your current code and I can take a brief look if I see something. (Can't seem to find the colored message in the repo you linked.)
i cannot use color codes in the repo if it's not working, if you want to reproduce locally, clone the repo, add a color code here, and run the main class here, if you want to try windows terminal build it and run the prebot jar in launcher/build/libs
if required i can make a test branch for you
i noticed a very important thing, i noticed that the compiled string contained the garbage, which means that this library might be innocent not causing any trouble
Yup, that was the problem. for anyone having this problem set your encoding in gradle to utf8 in all project (if multi module). Thanks for helping