Java 8 ConsoleHandler - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ConsoleHandler class.

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
     * @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:
    @Override 
    public StandardOutputCapture start() { 
        super.start(); 
        if (!reset) {
            LogManager.getLogManager().reset();
            Logger.getLogger("").addHandler(new ConsoleHandler());
            reset = true;
        } 
        return this;
    } 
} 
6
CodeRank
This code example shows how to use the following methods:setFormatter, setLevel
 
        configured = true;
    } 
    private static void resetLoggingHandlers() 
    { 
        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 
            { 
6
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
This code example shows how to use the following methods:setFormatter, setLevel
        logger.setLevel(java.util.logging.Level.FINEST);
        addConsoleHandler(SIMPLE_FORMATTER);
    } 
 
    private void addConsoleHandler(final ErlSimpleFormatter formatter) {
        consoleHandler = new ConsoleHandler();
        consoleHandler.setFormatter(formatter);
        final Level lvl = java.util.logging.Level.FINEST;
        consoleHandler.setLevel(lvl);
        logger.addHandler(consoleHandler);
    } 
 
    private void addFileHandler(final ErlSimpleFormatter formatter) {
        try { 
            fileHandler = new FileHandler(getLogLocation());
            fileHandler.setFormatter(formatter);
            fileHandler.setLevel(java.util.logging.Level.FINEST);
            logger.addHandler(fileHandler);
        } catch (final SecurityException e) {
            ErlLogger.error(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:setFilter, setFormatter, setLevel
    public void logToConsole() { 
        // to avoid cycles between logging and stdout 
        resetStdOutAndErr(); 
        logAsDefault(); 
 
        Handler handler = new ConsoleHandler();
        handler.setLevel(ALL);
        handler.setFilter(FILTER);
        handler.setFormatter(new SimpleFormatter());
        Logger logger = Logger.getLogger("");
        logger.addHandler(handler);
        // using ALL brings up a colored JavaFX WebView 
        // logger.setLevel(ALL); 
    } 
 
    public void logAsDefault() { 
        LogManager.getLogManager().reset();
    } 
 
    public String getLogFileAsString() {
6
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]");
6
CodeRank
This code example shows how to use the following methods:setFormatter, setLevel
     * Create the singleton logger instance 
     */ 
    static { 
        Log.LOGGER = Logger.getLogger("org.appwork");
        Log.LOGGER.setUseParentHandlers(false);
        final ConsoleHandler cHandler = new ConsoleHandler();
        cHandler.setLevel(Level.ALL);
        cHandler.setFormatter(new LogFormatter());
        Log.LOGGER.addHandler(cHandler);
        try { 
 
            final LogToFileHandler fh = new LogToFileHandler();
            fh.setFormatter(new FileLogFormatter());
            Log.LOGGER.addHandler(fh);
        } catch (final Exception e) {
            Log.exception(e);
        } 
 
        Log.LOGGER.addHandler(LogEventHandler.getInstance());
        Log.LOGGER.setLevel(Level.ALL);
5
CodeRank
See Code Examples for Java 8 ConsoleHandler Methods: