List of usage examples for java.util.logging Logger setLevel
public void setLevel(Level newLevel) throws SecurityException
From source file:Main.java
public static void setLoggerhandler(Logger logger) { Handler handler = new ExceptionHandler(); logger.addHandler(handler);//from w w w . ja va2s .c o m logger.setLevel(Level.ALL); }
From source file:com.mobius.software.mqtt.performance.controller.ControllerRunner.java
private static void configureConsoleLogger() { Logger l = Logger.getLogger("org.glassfish.grizzly.http.server.HttpHandler"); l.setLevel(Level.INFO); l.setUseParentHandlers(false);/*from w w w.j av a 2 s .c o m*/ ConsoleHandler ch = new ConsoleHandler(); ch.setLevel(Level.INFO); l.addHandler(ch); }
From source file:com.google.oacurl.util.LoggingConfig.java
public static void init(boolean verbose) throws SecurityException, IOException { System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger"); Logger defaultLogger = Logger.getLogger(""); if (verbose) { defaultLogger.setLevel(Level.INFO); } else {//from www.j a v a 2s. c om defaultLogger.setLevel(Level.SEVERE); } }
From source file:com.google.oacurl.util.LoggingConfig.java
public static void enableWireLog() { // For clarity, override the formatter so that it doesn't print the // date and method name for each line, and then munge the output a little // bit to make it nicer and more curl-like. Formatter wireFormatter = new Formatter() { @Override//from w w w. j av a2 s . co m public String format(LogRecord record) { String message = record.getMessage(); String trimmedMessage = message.substring(">> \"".length(), message.length() - 1); if (trimmedMessage.matches("[0-9a-f]+\\[EOL\\]")) { return ""; } trimmedMessage = trimmedMessage.replace("[EOL]", ""); if (trimmedMessage.isEmpty()) { return ""; } StringBuilder out = new StringBuilder(); out.append(message.charAt(0)); out.append(" "); out.append(trimmedMessage); out.append(System.getProperty("line.separator")); return out.toString(); } }; ConsoleHandler wireHandler = new ConsoleHandler(); wireHandler.setLevel(Level.FINE); wireHandler.setFormatter(wireFormatter); Logger wireLogger = Logger.getLogger("org.apache.http.wire"); wireLogger.setLevel(Level.FINE); wireLogger.setUseParentHandlers(false); wireLogger.addHandler(wireHandler); }
From source file:Main.java
/** * Tells Java's Logging infrastructure to output whatever it possibly can, this is only needed * in Java, not in Android./*from ww w . j av a 2 s . c o m*/ */ public static void outputAsMuchLoggingAsPossible() { Logger log = Logger.getLogger("com.couchbase.lite"); ConsoleHandler handler = new ConsoleHandler(); handler.setLevel(Level.ALL); log.addHandler(handler); log.setLevel(Level.ALL); }
From source file:com.canoo.dolphin.client.ClientContextFactory.java
/** * Create a {@link ClientContext} based on the given configuration. This method doesn't block and returns a * {@link CompletableFuture} to receive its result. If the {@link ClientContext} can't be created the * {@link CompletableFuture#get()} will throw a {@link ClientInitializationException}. * * @param clientConfiguration the configuration * @return the future/*from w w w . j a v a 2 s. c o m*/ */ public static CompletableFuture<ClientContext> connect(final ClientConfiguration clientConfiguration) { Assert.requireNonNull(clientConfiguration, "clientConfiguration"); final CompletableFuture<ClientContext> result = new CompletableFuture<>(); Level openDolphinLogLevel = clientConfiguration.getDolphinLogLevel(); Logger openDolphinLogger = Logger.getLogger("org.opendolphin"); openDolphinLogger.setLevel(openDolphinLogLevel); Executors.newSingleThreadExecutor().execute(() -> { try { final ForwardableCallback<DolphinRemotingException> remotingErrorHandler = new ForwardableCallback<>(); final ClientDolphin clientDolphin = new ClientDolphin(); clientDolphin.setClientModelStore(new ClientModelStore(clientDolphin)); final HttpClient httpClient = new DefaultHttpClient(new PoolingClientConnectionManager()); final ClientConnector clientConnector = new DolphinPlatformHttpClientConnector(clientDolphin, new OptimizedJsonCodec(), httpClient, clientConfiguration.getServerEndpoint(), remotingErrorHandler, clientConfiguration.getUiThreadHandler()); clientDolphin.setClientConnector(clientConnector); final DolphinCommandHandler dolphinCommandHandler = new DolphinCommandHandler(clientDolphin); final EventDispatcher dispatcher = new ClientEventDispatcher(clientDolphin); final BeanRepository beanRepository = new BeanRepositoryImpl(clientDolphin, dispatcher); final Converters converters = new Converters(beanRepository); final PresentationModelBuilderFactory builderFactory = new ClientPresentationModelBuilderFactory( clientDolphin); final ClassRepository classRepository = new ClassRepositoryImpl(clientDolphin, converters, builderFactory); final ListMapper listMapper = new ListMapperImpl(clientDolphin, classRepository, beanRepository, builderFactory, dispatcher); final BeanBuilder beanBuilder = new ClientBeanBuilderImpl(classRepository, beanRepository, listMapper, builderFactory, dispatcher); final ClientPlatformBeanRepository platformBeanRepository = new ClientPlatformBeanRepository( clientDolphin, beanRepository, dispatcher, converters); final ClientBeanManagerImpl clientBeanManager = new ClientBeanManagerImpl(beanRepository, beanBuilder, clientDolphin); final ControllerProxyFactory controllerProxyFactory = new ControllerProxyFactoryImpl( platformBeanRepository, dolphinCommandHandler, clientDolphin); final ClientContext clientContext = new ClientContextImpl(clientConfiguration, clientDolphin, controllerProxyFactory, dolphinCommandHandler, platformBeanRepository, clientBeanManager, remotingErrorHandler); clientDolphin.startPushListening(PlatformConstants.POLL_EVENT_BUS_COMMAND_NAME, PlatformConstants.RELEASE_EVENT_BUS_COMMAND_NAME); clientConfiguration.getUiThreadHandler() .executeInsideUiThread(() -> result.complete(clientContext)); } catch (Exception e) { result.obtrudeException(new ClientInitializationException("Can not connect to server!", e)); throw new ClientInitializationException(e); } }); return result; }
From source file:org.owasp.proxy.http.dao.JdbcMessageDAOTest.java
@BeforeClass public static void setUpBeforeClass() throws Exception { Logger dslogger = Logger.getLogger(DriverManagerDataSource.class.getName()); dslogger.setLevel(Level.OFF); dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName("org.h2.Driver"); dataSource.setUrl("jdbc:h2:mem:webscarab3;DB_CLOSE_DELAY=-1"); dataSource.setUsername("sa"); dataSource.setPassword(""); dao = new JdbcMessageDAO(); dao.setDataSource(dataSource);/*from w ww .j a va 2 s . c o m*/ }
From source file:name.livitski.tools.springlet.Logging.java
/** * Changes the log level applied to a subsystem by the JDK logging. * The new level will apply to the subsystem itself and to its * descendants that haven't been assigned severity levels explicitly. * @param level the lowest severity level of messages that will * be logged for selected subsystem(s) from now on * @param subsystem name of the subsystem that the new logging level * applies to, usually the name of a Java package or class, use * <code>null</code> to obtain the root logger from the JUL hierarchy * @see Logger#setLevel(Level)//from w w w. j a va2 s.co m * @see LogManager */ public static void setJDKLogLevel(Level level, String subsystem) { final String key = null == subsystem ? "" : subsystem; Logger logger = jdkLoggers.get(key); if (null == logger) { logger = Logger.getLogger(key); jdkLoggers.put(key, logger); } logger.setLevel(level); }
From source file:org.jumpmind.metl.StartWebServer.java
protected static void disableJettyLogging() { System.setProperty("org.eclipse.jetty.util.log.class", JavaUtilLog.class.getName()); Logger.getLogger(JavaUtilLog.class.getName()).setLevel(Level.SEVERE); Logger rootLogger = Logger.getLogger("org.eclipse.jetty"); for (Handler handler : rootLogger.getHandlers()) { handler.setLevel(Level.SEVERE); }//from www . j a v a 2 s . com rootLogger.setLevel(Level.SEVERE); }
From source file:havocx42.Program.java
private static void initRootLogger() throws SecurityException, IOException { FileHandler fileHandler;//from w w w . ja v a 2s.c o m fileHandler = new FileHandler("PRWeaponStats.%u.%g.txt", 1024 * 1024 * 8, 3, false); fileHandler.setLevel(Level.FINEST); fileHandler.setFormatter(new SimpleFormatter()); Logger rootLogger = Logger.getLogger(""); Handler[] handlers = rootLogger.getHandlers(); for (Handler handler : handlers) { handler.setLevel(Level.INFO); } rootLogger.setLevel(Level.FINEST); rootLogger.addHandler(fileHandler); }