java - Monitoring all output to the console -
i developing plugin program, bukkit, minecraft server, , need capture displayed in console. however, reason, unable this. following code use apply filters:
/** * */ package com.gmail.neonblue858.remoteconsole.plugin; import java.util.logging.level; import java.util.logging.logger; import org.bukkit.scheduler.bukkitrunnable; /** * * *@author meguy26 * */ public class filterapplyer extends bukkitrunnable { private clientmanager man; public filterapplyer(clientmanager man){ this.man = man; } /* (non-javadoc) * @see java.lang.runnable#run() */ @override public void run() { //create handler loghandler handler = new loghandler(man); //set handler capture handler.setlevel(level.all); //add handler root logger applies loggers logger.getlogger("").addhandler(handler); //set system out filtering output stream system.setout(new filteroutputstream(system.out, man)); //set system err filtering output stream system.seterr(new filteroutputstream(system.err, man)); } }
i under assumption applying filter root logger both system streams allow me catch everything. yet there messages escape filter. don't know why doesn't work. there way, other loggers or system.out, things can printed console?
note: clientmanager, loghandler, , filteroutputstream in above code classes wrote, , have ensured work properly. problem not applying filter every source of printing.
i under assumption applying filter root logger both system streams allow me catch everything.
from java logging overview:
by default logger log output messages parent's handlers, , on recursively tree.
when log records travel tree not passed logger.log(logrecord). if want capture need install handler on root logger , ensure loggers have useparenthanders set true.
you need aware root logger handlers created on demand.
Comments
Post a Comment