[SOLVED by Pandemoneus] Any way to remove MC server's log entries?

Discussion in 'Plugin Development' started by Nunnsy, Dec 10, 2011.

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

    Nunnsy

    Hey there,

    I was wondering if there was a Bukkit method to remove console messages sent my the original Minecraft Server. (Eg: opping player44)
    It would then not appear in the console or in the log.

    Please ask any question because it sounded a bit vague to myself.

    Any help would be appreciated.

    Thanks,
    - Nunnsy

    Or to somehow read and catch (stop) the output.

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

    fromgate Retired Staff

    Why you need it? I don't know why any plugin must hide log information from admins... if it's not a trojan...
     
  3. Offline

    Nunnsy

    Haha, no Trojan, it's for my server's use. I'll be sending logged items to a program and I need to remove certain logged things so that's why I was asking. Any suggestions?
     
  4. Offline

    Pandemoneus

    Hm. This is something I threw up and it is not complete, but that should work.

    Create a new class or make this a nested class and use this:

    Code:java
    1. public class MyFilter implements Filter {
    2. @Override
    3. public void isLoggable(LogRecord record) {
    4. String message = record.getMessage();
    5. if (message.contains(<certainStringsYouDoNotWant>)) {
    6. return false;
    7. }
    8. return true;
    9. }
    10. }


    Make a plugin and put this in your onEnable():

    Code:java
    1. public void onEnable() {
    2. Bukkit.getLogger().setFilter(new MyFilter());
    3. }


    You can also play around with the LogRecord object, just look at its JavaDoc.
     
    fromgate likes this.
  5. Offline

    Nunnsy

    You, are a legend! Thank-you so much!
     
  6. Offline

    Pandemoneus

    It doesn't work when plugins use System.out.println() though.
     
Thread Status:
Not open for further replies.

Share This Page