Solved "Remove from log"

Discussion in 'Plugin Development' started by Sw_aG, Apr 8, 2015.

?

Can you remove specific string from the log using a plugin?!

Poll closed May 23, 2015.
  1. Yes, i can!!

    0 vote(s)
    0.0%
  2. No, i don't know how to (Which is fine)

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

    Sw_aG

    Hi everyone, i'm having a problem with BarAPI, it spams my console like crazy but it is still working, can someone please right here an example code for how to delete a certain string from the log?


    Thanks in advance :D
     
  2. Offline

    nverdier

    @Sw_aG Please post what you have. We aren't here to spoonfeed you, we're here to help you with your current code.
     
    mine-care likes this.
  3. Offline

    Sw_aG

    I'm sorry if i made it look that way, but can you please AT LEAST tell me if its possible?
     
  4. Offline

    mine-care

    @Sw_aG if we can see the error it would be great, this way we can direct you to the patch
     
  5. @Sw_aG Only way I can think of is to modify BarAPI and remove the line printing out.
     
  6. Offline

    Sw_aG

    I've actually already tried to remove the try and catch fields but it is needed or something i don't really know how to do it Without it breaking the plugin.

    Do you know what it is?
     
  7. @Sw_aG I cannot see how removing a line printing could break anything. What is the line you are removing?
     
  8. Offline

    Sw_aG

    the "catch" line.
    To send you the whole method?
     
  9. Offline

    Ruptur

    @Sw_aG

    You could use a filter

    Filter class
    Code:
    public class ConsoleFilter implements Filter {
    
        @Override
        public boolean isLoggable(LogRecord record) {
            return !message.contains("[BarAPI]");// Dont know what messages barapi, guessing they have a prefix ;
        }
    }
    
    And in your onEnable method
    Code:
    ConsoleFilter filter = new ConsoleFilter();
    this.getLogger().setFilter(filter);
    
    To maximize the effect
    In your plugin.yml
    Code:
    name: whatever
    ...
    loadbefore: [BarApi]
    
     
  10. Offline

    Sw_aG

    The code before changing:
    [​IMG]

    And the code after:
    [​IMG]

    @Ruptur Sorry its kinda new to me i don't really know anything about filters...
     
    Last edited by a moderator: Apr 8, 2015
  11. Offline

    Ruptur

    @Sw_aG
    I gave an example above i can add comments if you want.

    If you want to remove the tracktraces. You dont remove the try & catch blocks
    Just remove the e.printStackTrace()
    Code:
    try {
    somethingtothrowerror
    } catch(Exception ignored) {}
    
     
  12. @Sw_aG So the plugin is throwing lots of errors? You might want to look into errors more than stop console spam. Even if you stop the spam the errors are there but if you fix the errors the spam is gone.
     
  13. Offline

    mine-care

    @Ruptur Traces are there for a reason, they are not thrown just because they can, they represent an error that occured.. "Muting" them does not take you out of harm's way, i recomend you post the error in console, here so we can read it, trace it and sugest a solution.
     
  14. Offline

    Ruptur

    @mine-care
    Question was :
    ... have problem with BarAPI ... spams my console ... please right here an example code for how to delete a certain string from the log?

    And i answered the question by giving an example.

    If you have a tip, tahg the thread owner not me.
    Thanks
     
  15. Offline

    Sw_aG

    Ahh, its all good, fixed everything, thank you every1 and have a good day! :D
    Moderators can now lock this thread (I used to know how)
     
Thread Status:
Not open for further replies.

Share This Page