当前位置: 首页>>代码示例>>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;未经允许,请勿转载。