[SOLVED]Change text color when using the logger

Discussion in 'Plugin Development' started by TechManDylan, Mar 28, 2012.

Thread Status:
Not open for further replies.
  1. Offline


    More or less what the title say I'm doing
     Bukkit.getServer().getLogger().warning(" PermissionsEx is not enabled.");
    and I was wondering if I could for instance make it red.
    I tried using ChatColor.RED but it gives an error.
    EDIT: Look below for what's currently going on
  2. Offline


    1. Bukkit.getServer().getLogger().severe(" PermissionsEx is not enabled.");
  3. Offline


    Didn't work I tried it and the text remained white. Any other ideas?
  4. How did ChatColor.RED give an error?

    Bukkit.getServer().getLogger().warning(ChatColor.RED + "PermissionsEx is not enabled.");
  5. Offline


    Oh wow I feel like a moron.... had a typo I have been staring at my screen to long thanks for the help looking at that made me realize it thank you
  6. Offline


    Please tell what the typo was, if other users have the same problem (for some reason) then a typo in ChatColor or whatever might be useful to know.
  7. Offline


    Oh lemme see if I can duplicate the error real quick and I will post it

    Oh well I just got around to testing this and using
    Bukkit.getServer().getLogger().warning( ChatColor.RED + "[Slimey Vines] PermissionsEx is not enabled.");
    Gives me this in the console
    07:35:03 [WARNING] ?c[Slimey Vines] PermissionsEx is not enabled.
    Any ideas as to why it's giving me "?c" instead of adding the chat color

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 24, 2016
  8. Offline


  9. Offline


    You need a different console. On linux it would work as is I believe. On windows you need to download some special command line program, I don't know what it is. Mac I don't know anything about those.
    For Web console, I guess it depends if the UI reads the log file or reads from the console.
  10. Offline

    Father Of Time

    It's because the windows platform is 100% incapable of ANSI escape sequences. It's an issue with legacy programming. Long story short it's impossible without using external libraries, like javacurse.



    Which is a library for console text color and boxed window development. Sorry, windows has just seemed to drop the ball on this one... *hates to ever admit that* :(
  11. Offline


    Well the weird thing is I'm on hosting this on my Mac Pro OSX Lion and I see other colored chat in the console so that's why I was a bit confused
  12. Offline


    Interesting. Maybe it's a bug, you should verify the leaky.
  13. Offline


    Ok now that something I don't know how to do, and would be ever so grateful if you explained. :D
  14. Offline


  15. Offline


    You guys are great just throwing that out there. Thanks for the link I shall scour the page and see if I can find anything.
  16. Offline


    Ok, here is why it isn't working, and why it cannot work.

    First, it is not a bug :D. A logger does not support the char ยง which is the makeup of the ChatColor , so the logger will replace it with a ?, and bukkit doesn't see that as a chatcolor, and doesn't replace the black text with the hexidecimal color value. You can use color tho for a commandsender in the console.
    TheKingElessar likes this.
  17. Offline


    Oh there we go you just saved me a little bit of digging thank you for helping get this figured out.
  18. Offline


    no prob :).
  19. Offline


    I had this same issue, and for anyone wondering, an easy way to fix it is use this code:

    Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "-message here-");
    ShadowSplicer and Ultimate_n00b like this.
  20. Offline


    (I think) A better way of doing this is triggering an event that normally sends a message to a player, and use a sendMessage.

    An example:
        public boolean Command(final CommandSender player, final Command inf, final String Label, final String[] args) {
            Player person = null;
            if (!(player instanceof Player)) {
                person = (Player) player;
            if (player == null){
                person.sendMessage("This is actually a person!");
                return false;
                player.sendMessage(ChatColor.BLUE + "This is sent to the console (i think)");
            return false;
  21. Offline


    I have the same problem here, Im trying to get my logger in color and I use the following:
        public void onEnable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + " v" + org.fusesource.jansi.Ansi.Color.GREEN + pdfFile.getVersion() + " Has Been Enabled!");
    I get the following below when I used this code:
    14:11:21 [INFO] [MAX HEAL] Enabling MAX HEAL v2.0
    14:11:21 [INFO] MAX HEAL vGREEN2.0 Has Been Enabled!
    What do I do to get it in code?
  22. Offline


  23. Offline


    I did but it didn't display it in color, I got just some kind of code when I ran the server
  24. Offline


    I believe it depends on the OS you use and how you start it. The coloring stuff to color in windows needs a third party thing installed. You should be able to find what it is on the forum somewhere.

    Edit: just checked for you, you need one of these :
    For windows 64bit : http://www.microsoft.com/en-nz/download/details.aspx?id=15336
    For windows 32bit: http://www.microsoft.com/en-nz/download/details.aspx?id=29
  25. Offline


    Listen to this guy.
    ShadowSplicer likes this.
  26. Offline


    I have Microsoft Visual C++ already, in fact, I have the 2010 version of it and some older versions of it. What do I do now
Thread Status:
Not open for further replies.

Share This Page