當前位置: 首頁>>代碼示例>>Java>>正文


Java ConsoleHandler.setLevel方法代碼示例

本文整理匯總了Java中java.util.logging.ConsoleHandler.setLevel方法的典型用法代碼示例。如果您正苦於以下問題:Java ConsoleHandler.setLevel方法的具體用法?Java ConsoleHandler.setLevel怎麽用?Java ConsoleHandler.setLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.logging.ConsoleHandler的用法示例。


在下文中一共展示了ConsoleHandler.setLevel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Server

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
public Server(String fileName, boolean restart) {
	super();
	parseServerFile(fileName);
	seatAssignments = new ArrayList<>(nSeats);
	for (int i = 0; i < nSeats; i++)
		seatAssignments.add("");

	log.getParent().removeHandler(log.getParent().getHandlers()[0]);
	
	try {
		// check if logs dir exists
		File logDir = new File("./logs/"); 
		if( !(logDir.exists()) )
			logDir.mkdir();
			
		FileHandler fh = new FileHandler("logs/server_log_" + serverID + ".log");
		fh.setFormatter(new SimpleFormatter());
		fh.setLevel(logLevel);
		log.addHandler(fh);
		
		ConsoleHandler ch = new ConsoleHandler();
		ch.setLevel(logLevel);
		log.addHandler(ch);
		log.setLevel(logLevel);
		
		log.info("Server initializing...");
		log.info("ServerID = " + serverID);
		log.info("nServers = " + nServers);
		log.info("nSeats = " + nSeats);
		log.info("my tcp port = " + tcpPort);
		for (int i = 0; i < nServers; i++)
			log.info("Server " + i + ": " + servers.get(i) + ":" + ports.get(i));
		log.info("Server init complete");
		log.info("--------------------------------");
		mutex = new LamportMutex(servers, ports, this, restart);
		mutex.init();
	} catch (SecurityException | IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:ericaddison,項目名稱:Dist_HW_2,代碼行數:41,代碼來源:Server.java

示例2: unitLogging

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
public static void unitLogging()
{
    // Start with a fresh root set at warning
    Logger root = LogManager.getLogManager().getLogger("");
    root.setLevel(Level.WARNING);
    for(Handler handler : root.getHandlers()) { root.removeHandler(handler); }

    //Logger.getLogger("java.util.prefs").setLevel(Level.SEVERE);
    Logger.getLogger("org.postgresql.jdbc").setLevel(Level.OFF);
    Logger.getLogger("org.postgresql.Driver").setLevel(Level.OFF);
    Logger.getLogger("org.wwscc").setLevel(Level.ALL);
    
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(Level.ALL);
    ch.setFormatter(new SingleLineFormatter());
    root.addHandler(ch);
}
 
開發者ID:drytoastman,項目名稱:scorekeeperfrontend,代碼行數:18,代碼來源:AppSetup.java

示例3: setupLogger

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
@Before
public void setupLogger() throws Exception {
    Level level = Level.INFO;
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {

        @Override
        public void uncaughtException(Thread t, Throwable e) {
            System.err.println("uncaughtException from thread " + t.getName() + ": " + e);
            e.printStackTrace();
        }
    });
    java.util.logging.LogManager.getLogManager().reset();
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(level);
    SimpleFormatter f = new SimpleFormatter();
    ch.setFormatter(f);
    java.util.logging.Logger.getLogger("").setLevel(level);
    java.util.logging.Logger.getLogger("").addHandler(ch);
}
 
開發者ID:diennea,項目名稱:majordodo,代碼行數:20,代碼來源:RestartBrokerAndStartWorkerTest.java

示例4: main

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
/**
 * Main entry point for the OpenOffice.org Bean Test.
 *
 * @param args arguments of the test
 *
 * @author Andreas Bröker
 * @date 21.05.2006
 */
public static void main(String[] args) throws OfficeApplicationException {

   LogManager.getLogManager().reset();
   ConsoleHandler consoleHandler = new ConsoleHandler();
   consoleHandler.setLevel(Level.FINEST);
   LOGGER.addHandler(consoleHandler);
   LOGGER.setLevel(Level.FINEST);

   try {
      FileHandler fileHandler = new FileHandler("log.xml");
      fileHandler.setLevel(Level.FINEST);
      LOGGER.addHandler(fileHandler);
   } catch (Throwable throwable) {
   }
   OfficeBeanTest testOfficeBean = new OfficeBeanTest();

   if (args.length == 0) {
      testOfficeBean.test(null);
   }else if (args.length == 1) {
      testOfficeBean.test(args[0]);
   }else if(args.length==4){
      testOfficeBean.remoteTestPDF(new File(args[2]), new File(args[3]), args[0], Integer.valueOf(args[1]));
   }else{
      System.out.println("usage:\nOfficeBeanTest host port source-odt target-pdf\nOfficeBeanTest officeHome");
   }
}
 
開發者ID:LibreOffice,項目名稱:noa-libre,代碼行數:35,代碼來源:OfficeBeanTest.java

示例5: redirectLogging

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
protected void redirectLogging() {
	final Logger rootLogger = LoggingSupport.getRootLogger();
	for (int i = 0; i < rootLogger.getHandlers().length; i++) {
		final Handler oldHandler = rootLogger.getHandlers()[i];
		if (oldHandler instanceof ConsoleHandler) {
			final ConsoleHandler newConsoleHandler = new ConsoleHandler();
			newConsoleHandler.setLevel(oldHandler.getLevel());
			newConsoleHandler.setFilter(oldHandler.getFilter());
			if (oldHandler.getFormatter() != null) {
				newConsoleHandler.setFormatter(oldHandler.getFormatter());
			}
			if (oldHandler.getErrorManager() != null) {
				newConsoleHandler.setErrorManager(oldHandler.getErrorManager());
			}
			try {
				newConsoleHandler.setEncoding(oldHandler.getEncoding());
			}
			catch (final UnsupportedEncodingException uee) {
				throw new IllegalStateException(uee);
			}
			rootLogger.removeHandler(oldHandler);
			rootLogger.addHandler(newConsoleHandler);
		}
	}
}
 
開發者ID:Albertus82,項目名稱:JFaceUtils,代碼行數:26,代碼來源:ScrollableConsole.java

示例6: setupLogging

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
private void setupLogging() {
    log.setUseParentHandlers(false);

    LogFormatter formatter = new LogFormatter();

    ConsoleHandler ch = new ConsoleHandler();
    ch.setFormatter(formatter);
    if (isDebugging()) {
        log.setLevel(Level.FINEST);
        ch.setLevel(Level.FINEST);
    } else {
        log.setLevel(Level.INFO);
        ch.setLevel(Level.INFO);
    }
    log.addHandler(ch);

    try {
        FileHandler fh = new FileHandler("server.log");
        fh.setFormatter(formatter);
        if (isDebugging()) {
            fh.setLevel(Level.FINEST);
        } else {
            ch.setLevel(Level.INFO);
        }
        log.addHandler(fh);
    } catch (IOException ex) {
        log.log(Level.SEVERE, "Error while adding FileHandler to logger. Logs will not be output to a file.", ex);
    }

}
 
開發者ID:OgarProject,項目名稱:Ogar2-Server,代碼行數:31,代碼來源:OgarServer.java

示例7: setUpConsoleHandler

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
/** Set up console handler */
public static Handler setUpConsoleHandler() {
	final ConsoleHandler handler = new ConsoleHandler() {
		@Override
		protected void setOutputStream(final OutputStream out) throws SecurityException {
			super.setOutputStream(System.out);
		}
	};
	handler.setLevel(Level.ALL);
	final Formatter formatter = new Formatter() {
		@Override
		public String format(final LogRecord record) {
			return record.getMessage();
		}
	};
	handler.setFormatter(formatter);
	return handler;
}
 
開發者ID:mast-group,項目名稱:sequence-mining,代碼行數:19,代碼來源:Logging.java

示例8: setupLogger

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
@Before
public void setupLogger() throws Exception {
    Level level = Level.SEVERE;
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {

        @Override
        public void uncaughtException(Thread t, Throwable e) {
            System.err.println("uncaughtException from thread " + t.getName() + ": " + e);
            e.printStackTrace();
        }
    });
    java.util.logging.LogManager.getLogManager().reset();
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(level);
    SimpleFormatter f = new SimpleFormatter();
    ch.setFormatter(f);
    java.util.logging.Logger.getLogger("").setLevel(level);
    java.util.logging.Logger.getLogger("").addHandler(ch);
}
 
開發者ID:diennea,項目名稱:majordodo,代碼行數:20,代碼來源:KerberosSimpleBrokerStatusReplicationTest.java

示例9: enableHttp2FrameLogging

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
private static void enableHttp2FrameLogging() {
  frameLogger = Logger.getLogger(Http2.class.getName());
  frameLogger.setLevel(Level.FINE);
  ConsoleHandler handler = new ConsoleHandler();
  handler.setLevel(Level.FINE);
  handler.setFormatter(new SimpleFormatter() {
    @Override public String format(LogRecord record) {
      return Util.format("%s%n", record.getMessage());
    }
  });
  frameLogger.addHandler(handler);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:Main.java

示例10: LoggingConfig

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
public LoggingConfig() {
    try {
        // Load a properties file from class path java.util.logging.config.file
        final LogManager logManager = LogManager.getLogManager();
        URL configURL = getClass().getResource("/logging.properties");
        if (configURL != null) {
            try (InputStream is = configURL.openStream()) {
                logManager.readConfiguration(is);
            }
        } else {
            // Programmatic configuration
            System.setProperty("java.util.logging.SimpleFormatter.format",
                               "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%1$tL %4$-7s [%3$s] %5$s %6$s%n");

            final ConsoleHandler consoleHandler = new ConsoleHandler();
            consoleHandler.setLevel(Level.FINEST);
            consoleHandler.setFormatter(new SimpleFormatter());

            final Logger app = Logger.getLogger("app");
            app.setLevel(Level.FINEST);
            app.addHandler(consoleHandler);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:27,代碼來源:LoggingConfig.java

示例11: ServerRunner

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
/**
 * Constructor.
 */
public ServerRunner() {
    log.setLevel(Level.ALL); 
    ConsoleHandler handler = new ConsoleHandler();
    handler.setFormatter(new SimpleFormatter());
    handler.setLevel(Level.ALL);
    log.addHandler(handler);

}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:12,代碼來源:ServerRunner.java

示例12: createShared

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
public static void createShared()
{
	globalLogger = Logger.getLogger("globalLogger");
	ConsoleHandler handler = new ConsoleHandler();
	globalLogger.addHandler(handler);
	handler.setLevel(Level.INFO);
	//LogFormatter formatter = new LogFormatter();
	//handler.setFormatter(formatter);
	globalLogger.setLevel( Level.INFO );
	sharedWV = new EventDrivenSharedWorldViewStub(globalLogger);
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:12,代碼來源:Test01_SharedWorldViewMultiAgent.java

示例13: main

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
public static void main(String[] args) {
    Logger log = Logger.getGlobal();
    ConsoleHandler handler = new ConsoleHandler();
    handler.setLevel(Level.ALL);
    log.addHandler(handler);
    log.setLevel(Level.ALL);
    JFrame fra = new JFrame("bitbox");
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    BaseConverter baseConverter = new BaseConverter();
    BitCombiner bitCombiner = new BitCombiner();
    BitPainter bitPainter = new BitPainter();
    SwingUtilities.invokeLater(() -> {
        fra.setSize(new Dimension(500, screenSize.height));
        fra.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        fra.setLayout(new GridLayout(GRID_SIZE, GRID_SIZE));
        fra.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
        fra.add(baseConverter);
        fra.add(bitCombiner);
        fra.add(bitPainter);
        fra.setVisible(true);
        log.fine("Created GUI");
    });
}
 
開發者ID:fusiled,項目名稱:bitbox,代碼行數:24,代碼來源:Main.java

示例14: config

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
/**
 * Configure Logger
 *
 * @throws IOException
 */
protected void config() throws IOException
{
    if( Boolean.parseBoolean(this.config.get("log_console_status", "false")) ){
        consoleHandler = new ConsoleHandler();
        log.addHandler(consoleHandler);
        if( this.config.get("log_console_level", "SEVERE").equals("ALL") ){
            consoleHandler.setLevel(Level.ALL);
        }else if( this.config.get("log_console_level", "SEVERE").equals("CONFIG") ){
            consoleHandler.setLevel(Level.CONFIG);
        }else if( this.config.get("log_console_level", "SEVERE").equals("FINE") ){
            consoleHandler.setLevel(Level.FINE);
        }else if( this.config.get("log_console_level", "SEVERE").equals("FINER") ){
            consoleHandler.setLevel(Level.FINER);
        }else if( this.config.get("log_console_level", "SEVERE").equals("FINEST") ){
            consoleHandler.setLevel(Level.FINEST);
        }else if( this.config.get("log_console_level", "SEVERE").equals("INFO") ){
            consoleHandler.setLevel(Level.INFO);
        }else if( this.config.get("log_console_level", "SEVERE").equals("OFF") ){
            consoleHandler.setLevel(Level.OFF);
        }else if( this.config.get("log_console_level", "SEVERE").equals("SEVERE") ){
            consoleHandler.setLevel(Level.SEVERE);
        }else if( this.config.get("log_console_level", "SEVERE").equals("WARNING") ){
            consoleHandler.setLevel(Level.WARNING);
        }
    }

    if( Boolean.parseBoolean(this.config.get("log_file_status", "false")) ){
        fileHandler  = new FileHandler(this.config.get("log_file_path", "src/main/java/resources/app.log"),
            Integer.parseInt(this.config.get("log_file_limit", "1")),
            Integer.parseInt(this.config.get("log_file_count", "200000")),
            Boolean.parseBoolean(this.config.get("log_file_append", "true"))
        );
        log.addHandler(fileHandler);
        if( this.config.get("log_file_level", "SEVERE").equals("ALL") ){
            fileHandler.setLevel(Level.ALL);
        }else if( this.config.get("log_file_level", "SEVERE").equals("CONFIG") ){
            fileHandler.setLevel(Level.CONFIG);
        }else if( this.config.get("log_file_level", "SEVERE").equals("FINE") ){
            fileHandler.setLevel(Level.FINE);
        }else if( this.config.get("log_file_level", "SEVERE").equals("FINER") ){
            fileHandler.setLevel(Level.FINER);
        }else if( this.config.get("log_file_level", "SEVERE").equals("FINEST") ){
            fileHandler.setLevel(Level.FINEST);
        }else if( this.config.get("log_file_level", "SEVERE").equals("INFO") ){
            fileHandler.setLevel(Level.INFO);
        }else if( this.config.get("log_file_level", "SEVERE").equals("OFF") ){
            fileHandler.setLevel(Level.OFF);
        }else if( this.config.get("log_file_level", "SEVERE").equals("SEVERE") ){
            fileHandler.setLevel(Level.SEVERE);
        }else if( this.config.get("log_file_level", "SEVERE").equals("WARNING") ){
            fileHandler.setLevel(Level.WARNING);
        }
    }
}
 
開發者ID:Clivern,項目名稱:Racter,代碼行數:60,代碼來源:Log.java

示例15: init

import java.util.logging.ConsoleHandler; //導入方法依賴的package包/類
/**
 * Initialize the logger
 */
public static void init() {

    ConsoleHandler handler = new ConsoleHandler();
    // PUBLISH this level
    handler.setLevel(Level.FINEST);
    LOGGER.addHandler(handler);
    LOGGER.setLevel(Level.FINEST);
}
 
開發者ID:luminoso,項目名稱:information-retrieval,代碼行數:12,代碼來源:Log.java


注:本文中的java.util.logging.ConsoleHandler.setLevel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。