How to disable Persistance/Ebean logging?

Discussion in 'Plugin Development' started by Wolfy9247, Apr 7, 2013.

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

    Wolfy9247

    If a plugin is using persistence, as is the one I'm currently working on, it seems to always print out the following upon server start:
    Code:
    [INFO] DataSourcePool autoCommit[false] transIsolation[SERIALIZABLE] min[2] max[20]
    [INFO] SubClassFactory parent ClassLoader [org.bukkit.plugin.java.PluginClassLoader]
    [INFO] Entities enhanced[0] subclassed[1]
    
    And upon creating a database:
    Code:
    [INFO] runScript
     [INFO] executing 1 of 1 create table ap_stats ( id
       integer primary key, protocol...
    [INFO] ... end of script
    
    I've yet to find any way to get rid of this.
     
  2. Offline

    Wolfy9247

    Bump! It's been about a month now with no answer; I assume nobody really knows, or it cannot be done. Either way, I'll try and give it at least one more chance.

    In addition to this, I've updated the OP with output I'd also like to mute when creating a database.
     
  3. Offline

    RROD

    Digging this up a bit...
    Looked into this tonight for my own uses. As far as I can see, it's a deeper issue with Ebean and not Bukkit (the way it handles logging). I can't see a viable workaround for it just now. Perhaps it might be time we found an alternative persistent database system, or get the current one working correctly. There's quite a lot of potential for a system like this.
     
  4. Offline

    Comphenix

    I haven't tested it, but I believe you can filter these messages (as they're simply printed to System.out) with a Logging filter:
    Code:java
    1. public class ExampleMod extends JavaPlugin implements Listener {
    2. @Override
    3. public void onEnable() {
    4.  
    5. Bukkit.getLogger().setFilter(new Filter() {
    6. @Override
    7. public boolean isLoggable(LogRecord record) {
    8. if ("runScript".equals(record.getMessage())) {
    9. return false;
    10. }
    11. return true;
    12. }
    13. });
    14.  
    15. System.out.println("runScript");
    16. System.out.println("testing");
    17. }
    18. }

    You will probably have to use a combination of regular expressions and a state machine to match these messages correctly.

    Another method would be to create the DldGenerator yourself, and set its private out field (of type PrintStream) to a custom PrintStream, such as new PrintStream(new ByteArrayOutputStream()):
    Code:java
    1.  
    2. public class ExampleMod extends JavaPlugin implements Listener {
    3. protected void installDDL() {
    4. SpiEbeanServer serv = (SpiEbeanServer)getDatabase();
    5. DdlGenerator gen = serv.getDdlGenerator();
    6.  
    7. // Set "out" to a custom PrintStream here!
    8.  
    9. gen.runScript(false, gen.generateCreateDdl());
    10. }
    11. }
    12.  


    It's amazing what you can find when you decompile craftbukkit with JD-GUI into a directory of source files, and then search for the message that gets printed to the console. Saves me a lot of trouble tracking things down.
     
Thread Status:
Not open for further replies.

Share This Page