List of usage examples for java.util.logging Logger setFilter
public void setFilter(Filter newFilter) throws SecurityException
From source file:Person.java
public static void main(String args[]) { Logger logger = Logger.getLogger("your.logging"); AgeFilter filter = new AgeFilter(); logger.setFilter(filter); Person person = new Person("YourName", 32); logger.log(Level.INFO, "Person has age " + person.getAge(), person); }
From source file:org.freaknet.gtrends.client.GoogleTrendsClientFactory.java
private static void setLogLevel(CmdLineParser cmdLine) throws SecurityException, IllegalArgumentException { final Level level; if (cmdLine.getLogLevel() != null) { level = Level.parse(cmdLine.getLogLevel()); } else {/*from ww w.j a v a2 s .c om*/ level = Level.parse(DEFAULT_LOGGING_LEVEL); } Logger log = LogManager.getLogManager().getLogger(""); for (Handler h : log.getHandlers()) { log.removeHandler(h); } Handler handler = new ConsoleHandler(); handler.setFormatter(new LogFormatter()); handler.setLevel(level); log.setUseParentHandlers(false); Logger defaultLog = Logger.getLogger(GoogleConfigurator.getLoggerPrefix()); defaultLog.addHandler(handler); defaultLog.setLevel(level); defaultLog.setFilter(new Filter() { @Override public boolean isLoggable(LogRecord record) { if (record.getSourceClassName().startsWith(GoogleConfigurator.getLoggerPrefix())) { return (record.getLevel().intValue() >= level.intValue()); } return false; } }); }
From source file:de.ailis.jasdoc.Main.java
/** * Initializes logging.// w w w . jav a 2 s.c om */ private void initLogging() { final Logger logger = Logger.getLogger("de.ailis.jasdoc"); logger.setUseParentHandlers(false); final Handler handler = new LogHandler(); handler.setFilter(null); handler.setFormatter(new LogFormatter(this.debug)); if (this.debug) handler.setLevel(Level.ALL); else if (this.quiet) handler.setLevel(Level.WARNING); else handler.setLevel(Level.INFO); logger.setFilter(null); logger.addHandler(handler); Logger.getLogger("").setLevel(handler.getLevel()); }
From source file:ubic.pubmedgate.mallet.MalletQuick.java
private void silenceLogger(java.util.logging.Logger logger) { logger.setFilter(new MalletLogFilter()); }