List of usage examples for java.util.logging Handler setFormatter
public synchronized void setFormatter(Formatter newFormatter) throws SecurityException
From source file:eu.abc4trust.abce.pertubationtests.tud.section2.PA_II_2_2_7randomUID.java
@BeforeClass public static void setupLogger() throws SecurityException, IOException { Handler fh = new FileHandler("PA-Section-2.2.7randomUID.log"); SimpleFormatter simpleFormatter = new SimpleFormatter(); fh.setFormatter(simpleFormatter); logger.addHandler(fh);/*w ww .j a v a2 s . c om*/ }
From source file:org.openqa.selenium.server.log.LoggingManager.java
protected static void restoreOriginalHandlersFormattersAndLevels(Logger logger) { for (Handler handler : logger.getHandlers()) { logger.removeHandler(handler);// ww w . j ava 2 s . c om } for (Handler handler : originalHandlers) { logger.addHandler(handler); // jbevan: java.util.logging.RestishHandler.setFormatter(null) throws an NPE if (originalFormatters.get(handler) != null) { handler.setFormatter(originalFormatters.get(handler)); } handler.setLevel(originalLogLevels.get(handler)); } }
From source file:org.openqa.selenium.server.log.LoggingManager.java
public static void overrideSimpleFormatterWithTerseOneForConsoleHandler(Logger logger, boolean debugMode) { for (Handler handler : logger.getHandlers()) { if (handler instanceof ConsoleHandler) { final Formatter formatter; formatter = handler.getFormatter(); if (formatter instanceof SimpleFormatter) { final StdOutHandler stdOutHandler; final Level originalLevel; /*/*from w w w. jav a 2 s . c o m*/ * DGF - Nobody likes the SimpleFormatter; surely they wanted our terse formatter instead. */ originalLevel = handler.getLevel(); handler.setFormatter(new TerseFormatter(false)); handler.setLevel(Level.WARNING); /* * Furthermore, we all want DEBUG/INFO on stdout and WARN/ERROR on stderr */ stdOutHandler = new StdOutHandler(); stdOutHandler.setFormatter(new TerseFormatter(false)); stdOutHandler.setFilter(new MaxLevelFilter(Level.INFO)); stdOutHandler.setLevel(originalLevel); logger.addHandler(stdOutHandler); if (debugMode) { if (originalLevel.intValue() > Level.FINE.intValue()) { stdOutHandler.setLevel(Level.FINE); } } } } } }
From source file:net.mmberg.nadia.processor.NadiaProcessor.java
private void init() { init = true;//from w w w. j av a 2 s . c o m startedOn = new Date(); //format logging logger.setUseParentHandlers(false); CustomFormatter fmt = new CustomFormatter(); Handler ch = new ConsoleHandler(); ch.setFormatter(fmt); logger.addHandler(ch); logger.setLevel(Level.INFO); }
From source file:org.ensembl.healthcheck.testcase.AbstractPerlModuleBasedTestCase.java
protected void removePerlFriendlyLogFormatters() { for (Handler h : logger.getHandlers()) { h.setFormatter(savedFormatter.get(h)); }/*from w w w.j av a 2 s . c o m*/ }
From source file:de.ailis.jasdoc.Main.java
/** * Initializes logging.//ww w . j av 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:org.ensembl.healthcheck.testcase.AbstractPerlModuleBasedTestCase.java
protected void setPerlFriendlyLogFormatters() { Handler[] configuredHandler = logger.getHandlers(); // It is possible that no Handler has been configured. In that case we // create and add one to the logger. ///*from w w w. j a va 2 s . c o m*/ if (configuredHandler.length == 0) { logger.addHandler(new ConsoleHandler()); configuredHandler = logger.getHandlers(); } // Now there is at least one configuredHandler. // for (Handler h : configuredHandler) { savedFormatter.put(h, h.getFormatter()); h.setFormatter(perlLogMessagesFormatter); if (h.getFormatter() != perlLogMessagesFormatter) { throw new RuntimeException("Unable to set Formatter!"); } } }
From source file:org.openqa.selenium.server.SingleEntryAsyncQueueUnitTest.java
private void configureLogging() throws Exception { LoggingManager.configureLogging(new LoggingOptions(), true); Logger logger = Logger.getLogger(""); for (Handler handler : logger.getHandlers()) { if (handler instanceof StdOutHandler) { handler.setFormatter(new TerseFormatter(true)); break; }/*from w w w . ja va 2 s .co m*/ } }
From source file:node.Mailbox.java
/** * set up the mailbox//from w ww .j a v a 2s . co m * * @param _msgsSend * @param _evolveMsgsRecv * @param _ctrlMsgsRecv * @param reportSend2 */ public Mailbox(int _port, NodeList _nodeList, BlockingQueue<ControlMessage> _ctrlMsgsRecv, BlockingQueue<EvolveMessage> _evolveMsgsRecv, BlockingQueue<MessageWrapper<AbstractMessage>> _msgsSend, BlockingQueue<JSONObject> _reportSend) { // for now, hard-code REPORT to false REPORT = false; ctrlMsgsRecv = _ctrlMsgsRecv; evolveMsgsRecv = _evolveMsgsRecv; msgsSend = _msgsSend; reportSend = _reportSend; port = _port; nodeList = _nodeList; shutdown = false; try { log.setUseParentHandlers(false); Handler fh = new FileHandler("mailbox.log"); fh.setFormatter(new TextFormatter()); log.addHandler(fh); log.setLevel(Level.ALL); } catch (SecurityException e) { e.printStackTrace(); log.severe(ExceptionUtils.getStackTrace(e)); } catch (IOException e) { e.printStackTrace(); log.severe(ExceptionUtils.getStackTrace(e)); } Control.logOneTime("Mailbox started up"); }
From source file:com.intuit.tank.proxy.Main.java
public void start() { try {/*from w w w .ja va 2s .com*/ application.startSession(this); logger.setUseParentHandlers(false); Handler ch = new ConsoleHandler(); ch.setFormatter(new TextFormatter()); logger.addHandler(ch); InetSocketAddress listen; try { listen = new InetSocketAddress("localhost", port); } catch (NumberFormatException nfe) { usage(); return; } String proxy = "DIRECT"; final ProxySelector ps = getProxySelector(proxy); DefaultHttpRequestHandler drh = new DefaultHttpRequestHandler() { @Override protected HttpClient createClient() { HttpClient client = super.createClient(); client.setProxySelector(ps); client.setSoTimeout(20000); return client; } }; ServerGroup sg = new ServerGroup(); sg.addServer(listen); drh.setServerGroup(sg); HttpRequestHandler rh = drh; rh = new LoggingHttpRequestHandler(rh); BufferedMessageInterceptor bmi = new BufferedMessageInterceptor() { @Override public Action directResponse(RequestHeader request, MutableResponseHeader response) { // System.err.println(new String(request.getHeader()) // + "+++++++++++\n" + new String(response.getHeader()) // + "==========="); return Action.BUFFER; } @Override public Action directRequest(MutableRequestHeader request) { // System.err.println(new String(request.getHeader()) // + "==========="); return Action.BUFFER; } }; rh = new BufferingHttpRequestHandler(rh, bmi, 1024 * 1024, application); HttpProxyConnectionHandler hpch = new HttpProxyConnectionHandler(rh); SSLContextSelector cp = getSSLContextSelector(); TargetedConnectionHandler tch = new SSLConnectionHandler(cp, true, hpch); tch = new LoopAvoidingTargetedConnectionHandler(sg, tch); hpch.setConnectHandler(tch); TargetedConnectionHandler socks = new SocksConnectionHandler(tch, true); p = new Proxy(listen, socks, null); p.setSocketTimeout(90000); p.start(); } catch (Exception e) { throw new RuntimeException(e); } }