Solved Suppress console/log output of "<user> issued server command: <command here>" for specific commands

Discussion in 'Spigot Plugin Development' started by BillyGalbreath, Jul 2, 2016.

  1. Anyone know the best way to suppress the console/log output of "user issued server command: <command here>" for specific commands (and their aliases)? I wish to suppress my chat channel commands from showing in console because the formatted chat is broadcasted and just doubles the log:


    I dont want to suppress _all_ the commands. Just my plugin's commands. I've seen plugins in the past do this (like authme to hide /login password, etc etc).

    Hoping to find a better way than adding a log4j filter :S
  2. Have you tried using the command preprocess event and cancelling it instead of CommandExecutors? That might cause it to not go through to the console.
  3. I did. And I'm hoping for something else (high hopes, I know).

    See, my chat channels are controlled via the /channel command. And theres a lot of ways to trigger them

    /channel - lists available channels you have permission to talk to
    /channel name - joins specified channel (all future chats will go to this channel for the session)
    /channel name message - sends the message to specified channel without joining it

    Then come the aliases /ch and /c with the above mentioned rules applied. These aliases are registered in plugin.yml.

    Then the dynamic shortcut channels /name (channel name) and /n (first letter of channel name) with the possibility of server owner specified shortcut aliases too, all with the above mentioned rules still applied. These are not registered anywhere and I'm already utilizing command preprocess event to rewrite the command to it's longer version so the command system handles it:

    Code (Text):

    * Listen to player commands for any channel aliases
    @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
    public void onPlayerPreCommand(PlayerCommandPreprocessEvent event) {
        String alias = event.getMessage().substring(1);
        List<String> split = new ArrayList<>(Arrays.asList(alias.split(" ")));
        if (split.size() > 0) {
            alias = split.get(0);
        Channel channel = ChannelManager.getManager().getChannel(alias);
        if (channel == null) {
        event.setMessage("/ch " + channel.getColorlessName() + " " + String.join(" ", split));
    So, as you see, I'm really in a pickle here. Its really late (3am) and I havent slept in 3 days, so my mind is kinda bonked out. So Here I am hoping someone knows of a fancy little way to hook into the command system and suppress those messages. Its a real long shot, I know. And I'm most likely going to end up doing what you just suggested anyways. But, I'll leave this question up overnight and go try to get some actual sleep. Maybe I'll be able to think better in the morning :p
  4. Well, that's the only solution I can think of, but I'm there in the sleep deprivation hole with you! :p Maybe someone in a different timezone will wake up and give us something gold. Good luck with your problem :)
  5. Just thought about it after re-reading my last post for typos.. The console output shows the raw command, not what my command preprocess is rewriting, so I dont think preprocess will work. Its outputing to console/log before even the lowest priority.. Or its handled elsewhere.. Hmm.. :S
  6. Huh. Might have to use a packet listener or something like that?
    • Winner Winner x 1
    • Useful Useful x 1
  7. Seems like the way to go, then, unless there's some specific reason why not.

    By the way, @BillyGalbreath we must be psychically connected or something. Just this very week, I started working on a chat plugin and one of the main features of it is channels. :p
    • Agree Agree x 1
  8. Under PlayerConnection:

    Code (Text):
        if (SpigotConfig.logCommands) {
 + " issued server command: " + s);
    SO you have two optimal ways of preventing this without having to filter the logs. You could disable command logging all together, or override/edit PlayerConnection.
    • Winner Winner x 1
  9. Indeed you are correct. The command is logged before preprocess. Looks like I'm using log4j filters.


    Well, I wrote my chat plugin years ago. I'm just updating it now because the one my server's been using is not compatible with the DiscordBot we're currently using (the stupid bot is sending private channels to a public discord). So, I wrote a new DiscordBot that wouldn't do that. When I cracked open the chat plugin we're using to make my bot compatible with it I about screamed at what I saw. So now I'm updating my old chat plugin so we can use it and my bot instead ^_^
  10. Added the log filter. Works like a charm ^_^


    Marking thread solved.