Handler setLevel - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Handler setLevel method.

This code example shows how to use the following methods:setFormatter, setLevel
      logFile = options.getLogOutFile();
      fileHandler = seleniumFileHandlers.get(logFile);
      if (fileHandler == null) {
        fileHandler = registerNewSeleniumFileHandler(logFile);
      } 
      fileHandler.setFormatter(new TerseFormatter(true));
      currentLogger.setLevel(Level.FINE);
      fileHandler.setLevel(Level.FINE);
      currentLogger.addHandler(fileHandler);
      return logFile;
    } catch (IOException e) {
      throw new RuntimeException(e);
    } 
  } 
 
  private static FileHandler registerNewSeleniumFileHandler(File logFile) throws IOException {
    FileHandler fileHandler;
    fileHandler = new FileHandler(logFile.getAbsolutePath());
    seleniumFileHandlers.put(logFile, fileHandler);
    return fileHandler;

8
CodeRank
This code example shows how to use the following methods:setFormatter, setLevel
        logger.setUseParentHandlers(false);
        logger.setLevel(java.util.logging.Level.FINEST);
    } 
 
    private void addConsoleHandler(final ErlSimpleFormatter erlSimpleFormatter) {
        consoleHandler = new ConsoleHandler();
        consoleHandler.setFormatter(erlSimpleFormatter);
        final Level lvl = java.util.logging.Level.FINEST;
        consoleHandler.setLevel(lvl);
        logger.addHandler(consoleHandler);
    } 
 
    private void addFileHandler(final ErlSimpleFormatter erlSimpleFormatter) {
        try { 
            fileHandler = new FileHandler(getLogLocation());
            fileHandler.setFormatter(erlSimpleFormatter);
            fileHandler.setLevel(java.util.logging.Level.FINEST);
            logger.addHandler(fileHandler);
        } catch (final SecurityException e) {
            ErlLogger.error(e);
7
CodeRank
This code example shows how to use the following methods:setFormatter, setLevel
    { 
        ConsoleLogThread.wrappedHandler.setLevel(Level.parse(System.getProperty("fml.log.level","INFO")));
        // Console handler captures the normal stderr before it gets replaced 
        log.myLog.addHandler(new ConsoleLogWrapper());
        ConsoleLogThread.wrappedHandler.setFormatter(formatter);
        fileHandler.setLevel(Level.ALL);
        fileHandler.setFormatter(formatter);
        log.myLog.addHandler(fileHandler);
    } 
 
    public static void loadLogConfiguration(File logConfigFile)
    { 
        if (logConfigFile!=null && logConfigFile.exists() && logConfigFile.canRead())
        { 
            try 
            { 
                LogManager.getLogManager().readConfiguration(new FileInputStream(logConfigFile));
                resetLoggingHandlers(); 
            } 
            catch (Exception e)
7
CodeRank
This code example shows how to use the following methods:setFormatter, setLevel
     * @param args command-line arguments 
     * @throws DatabaseException 
     * @throws IOException 
     */ 
    public static void main(String[] args) throws DatabaseException, IOException {
        Handler handler = new ConsoleHandler();
        handler.setLevel(Level.ALL);
        handler.setFormatter(new OneLineSimpleLogger());
        logger.addHandler(handler);
        logger.setUseParentHandlers(false);
 
        if (args.length == 2) {
            logger.setLevel(Level.INFO);
            populatePersistEnv(args[0], new File(args[1]));
        } else if (args.length == 1) {
            logger.setLevel(Level.FINE);
            populatePersistEnv(args[0], null);
        } else { 
            System.out.println("Arguments: ");
            System.out.println("    source [target]");
7
CodeRank
This code example shows how to use the following methods:getLevel, setLevel, close, publish, flush
 
		// start the server to be ready to accept log messages 
		ServerThread thread = new ServerThread();
		thread.start();
		Thread.sleep(2000);
		h = new SocketHandler();
		h.setLevel(Level.FINE);
 
		assertSame(h.getLevel(), Level.FINE);
		LogRecord r = new LogRecord(Level.INFO, "testPublish_NoFormatter");
		assertTrue(h.isLoggable(r));
		h.close();
		// ensure the thread exits and the port becomes available again 
		thread.getReadString();
		// assertFalse(h.isLoggable(r)); 
		h.publish(r);
		h.flush();
		// assertEquals("MockFormatter_Head", 
		// this.errSubstituteStream.toString()); 
	} 

6
CodeRank
This code example shows how to use the following methods:setFilter, setFormatter, setLevel
    } 
       
    Logger logger = Logger.getLogger(getName());
 
    if (! (logger instanceof EnvironmentLogger)) {
      CloseListener listener = new CloseListener(_handler);
 
      Environment.addClassLoaderListener(listener);
    } 
     
    // env/02s9 
    if (_level != null)
      _handler.setLevel(_level);
 
    /* JDK defaults to Level.ALL 
    if (_level != null) 
      _handler.setLevel(_level); 
    else 
      _handler.setLevel(Level.INFO); 
    */ 

6
CodeRank
This code example shows how to use the following methods:setLevel
    public ByteArrayOutputStream baos;
    public StreamHandler streamHandler;
 
    public StubLogger() { 
        baos = new ByteArrayOutputStream(10000);
        streamHandler = new StreamHandler(baos, new SimpleFormatter());
        streamHandler.setLevel(Level.ALL);
        Logger logger = Logger.getLogger("");
        logger.addHandler(streamHandler);
    } 
 
    /** 
     * Returns any new java.util.logging messages since this method was last called,  
     * or since this object was constructed if this method has not yet been called. 
     */ 
    public String getNewLogMessages() {
        streamHandler.flush();
        String text = baos.toString();
        baos.reset();
        return text;
6
CodeRank
This code example shows how to use the following methods:setEncoding, setFilter, setFormatter, setLevel
        final String formatter = manager.getProperty(className + ".formatter");
        setFormatter(makeFormatter(formatter));
         
        final String encoding = manager.getProperty(className + ".encoding");
        try { 
            this.stdOutHandler.setEncoding(encoding);
            this.stdErrHandler.setEncoding(encoding);
        } catch (final UnsupportedEncodingException e) {
            Log.logException(e);
        } 
         
        final String ignoreCtrlChrStr = manager.getProperty(className + ".ignoreCtrlChr");
        this.ignoreCtrlChr = (ignoreCtrlChrStr==null) ? false : "true".equalsIgnoreCase(ignoreCtrlChrStr);
         
    }     
     
    private Level parseLevel(final String levelName) {
        try { 
            return (levelName == null) ? Level.INFO : Level.parse(levelName);
        } catch (final Exception e) {

6
CodeRank
This code example shows how to use the following methods:setEncoding, setFormatter, setLevel
 
public final class Utils { 
 
	private static final Logger logger;
	static { 
		Handler handler = new ConsoleHandler();
		handler.setLevel(Level.ALL);
		handler.setFormatter(new SimpleFormatter());
		try { 
			handler.setEncoding("utf-8");
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		} 
		logger = Logger.getLogger(Utils.class.getPackage().getName());
		logger.setLevel(Level.ALL);
		logger.addHandler(handler);
		logger.setUseParentHandlers(false);
	} 
5
CodeRank
This code example shows how to use the following methods:setLevel
 
	private SelectorThread threadSelector;
	private String baseUri;
 
	public TestServer(String aPackage) throws IllegalArgumentException, IOException {
		Handler h = new ConsoleHandler(); h.setLevel(Level.ALL);
		Logger.getLogger("").addHandler(h);
		 
		baseUri = "http://localhost:9998/";
		final Map<String, String> initParams = new HashMap<String, String>();
 
		initParams.put("com.sun.jersey.config.property.packages",
				aPackage);
 
		System.out.println("Starting grizzly...");
		threadSelector = GrizzlyWebContainerFactory.create(baseUri, initParams);
		System.out.println(String
				.format("Jersey app started with WADL available at %sapplication.wadl\n", baseUri));
	} 
	 
6
CodeRank
setLevel Method Overview
Set the log level specifying which message levels will be logged by this Handler.
See Code Examples for other Java 8 Handler Methods: