Solved Block console log for specific command

Discussion in 'Spigot Plugin Development' started by NyanGuyMF, Jan 14, 2019.

Thread Status:
Not open for further replies.
  1. How can I block logging for specific command?
    Code (Java):
    [time INFO]: Player issued server command: /command

    At this point I've tried use this code, but it doesn't work:

    Code (Java):
    getLogger().setFilter(new Filter() {
        @Override
        public boolean isLoggable(LogRecord record) {
            return !record.getMessage().contains("/command");
        }
    });
     
  2. Try applying a filter to sys out the same way, as both the logger and sys out point to the same output.
     
  3. I think you're filtering on the wrong logger instance.
    Code (Java):
    Logger.getLogger("Minecraft");
    is the logger from the spigot server itself,
    Code (Java):
    getLogger();
    returns the logger from the plugin.
    if you use this logger your log msg will get your plugin prefix.
     
  4. It also doesn't work
     
  5. How to apply it to System.out? ':D
     
  6. Perhaps something like this?
    https://stackoverflow.com/questions/30066313/reading-system-out
    Also, assuming this is still spigot's default message notifying the sys out, have you checked the spigot source to see where it sends this, and if there is a config location where you can disable it?
     
  7. I gonna check this way now :D
    Do, I didn't, thanks)
     
  8. The example uses Integer value to write, how could I analyzing String values?
    Code (Java):

    class AnalyzingOutputStream extends FilterOutputStream {
        public AnalyzingOutputStream (OutputStream out) {
            super(out);
        }

        @Override
        public void write(int b) {
              // do whatever analysis you want
            try {
                super.write(b);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
     
  9. Well it's just an example using a FilterOutputStream. sys out is a PrintStream, which extends FilterOutputStream. You can just as easily extend PrintStream instead of FilterOutputStream if you like and override its internal methods (including print, println, printf, etc.)
     
Thread Status:
Not open for further replies.

Share This Page