当前位置: 首页>>代码示例>>Java>>正文


Java Handler.setLevel方法代码示例

本文整理汇总了Java中java.util.logging.Handler.setLevel方法的典型用法代码示例。如果您正苦于以下问题:Java Handler.setLevel方法的具体用法?Java Handler.setLevel怎么用?Java Handler.setLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.logging.Handler的用法示例。


在下文中一共展示了Handler.setLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setHandlers

import java.util.logging.Handler; //导入方法依赖的package包/类
private void setHandlers(Logger logger, File file) throws FileNotFoundException {
  	for (Handler h : logger.getHandlers()) {
  		logger.removeHandler(h);
  	}
      Handler stderrHandler = new FlushedStreamHandler(System.err, noColors ? CommandLineLogFormatter.INSTANCE : CommandLineLogFormatter.COLORS);
      logger.addHandler(stderrHandler);
      if (file == null)
	stderrHandler.setLevel(logLevel);
else {
	File dir = file.getParentFile();
	if (dir != null) {
		dir.mkdirs();
	}
          Handler fileHandler = new FlushedStreamHandler(new FileOutputStream(file, appendToLog), CommandLineLogFormatter.INSTANCE);
          logger.addHandler(fileHandler);
          if (logLevel.intValue() < Level.FINE.intValue()) {
              fileHandler.setLevel(logLevel);
              stderrHandler.setLevel(Level.FINE);
          }
          else {
              fileHandler.setLevel(Level.FINE);
              stderrHandler.setLevel(logLevel);
          }
      }
  }
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:26,代码来源:AbstractAlvisNLP.java

示例2: PlanBuilder

import java.util.logging.Handler; //导入方法依赖的package包/类
public PlanBuilder(File planDir, File resourceDir) {
	super();

	this.planDir = planDir;
	this.resourceDir = resourceDir;

	logger = Logger.getLogger(ALVISNLP_LOGGER_NAME);
	Level logLevel = Level.INFO;
	logger.setLevel(logLevel);
	logger.setUseParentHandlers(false);
   	for (Handler h : logger.getHandlers()) {
   		logger.removeHandler(h);
   	}
   	Handler stderrHandler = new FlushedStreamHandler(System.err, CommandLineLogFormatter.INSTANCE);
   	logger.addHandler(stderrHandler);
   	stderrHandler.setLevel(logLevel);
   	
       moduleFactory = new CompoundCorpusModuleFactory();
       moduleFactory.loadServiceFactories(CorpusModuleFactory.class, null, null, null);

       converterFactory = new CompoundParamConverterFactory();
       converterFactory.loadServiceFactories(ParamConverterFactory.class, null, null, null);
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:24,代码来源:PlanBuilder.java

示例3: disableLogging

import java.util.logging.Handler; //导入方法依赖的package包/类
public static void disableLogging() {
	// Disable Logging (FastSet sometimes complains about skewed key distributions with lots of WARNINGs)
	Logger root = Logger.getLogger("");
	Handler[] handlers = root.getHandlers();
	for (Handler handler : handlers)
		handler.setLevel(Level.OFF);
}
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:8,代码来源:LoggingUtils.java

示例4: setLogging

import java.util.logging.Handler; //导入方法依赖的package包/类
static void setLogging(Level level) {	
if (LOGGER.getHandlers().length == 0) {
           //System.setProperty("java.util.logging.SimpleFormatter.format", "[%4$s] MixThem: %5$s [%1$tc]%n");            
    System.setProperty("java.util.logging.SimpleFormatter.format", "[%4$s] MixThem: %5$s%n");
    LOGGER.setUseParentHandlers(false);	 
    LOGGER.setLevel(Level.ALL);
    Handler handler = new ConsoleHandler();
    LOGGER.addHandler(handler);        
    handler.setLevel(Level.OFF);
    String prop = System.getProperty("mixthem.logging");
           if (prop == null || prop.equals("true")) {
               handler.setLevel(level);            
           }
}
   }
 
开发者ID:Innovimax-SARL,项目名称:mix-them,代码行数:16,代码来源:MixThem.java

示例5: setGlobalLevel

import java.util.logging.Handler; //导入方法依赖的package包/类
public static void setGlobalLevel(Level newLevel) {
  Logger rootLogger = LogManager.getLogManager().getLogger("");
  rootLogger.setLevel(newLevel);
  for (Handler h : rootLogger.getHandlers()) {
    h.setLevel(newLevel);
  }
}
 
开发者ID:XDean,项目名称:Java-EX,代码行数:8,代码来源:LogUtil.java

示例6: setHandlers

import java.util.logging.Handler; //导入方法依赖的package包/类
public void setHandlers(Logger logger, Level logLevel) throws FileNotFoundException {
	for (Handler h : logger.getHandlers()) {
		logger.removeHandler(h);
	}
	Handler stderrHandler = new FlushedStreamHandler(System.err, CommandLineLogFormatter.INSTANCE);
	logger.addHandler(stderrHandler);
	stderrHandler.setLevel(logLevel);

	Handler fileHandler = new FlushedStreamHandler(new FileOutputStream(new File(processingDir, ALVISNLP_LOG_FILENAME), false), CommandLineLogFormatter.INSTANCE);
    logger.addHandler(fileHandler);
	fileHandler.setLevel(logLevel);
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:13,代码来源:Run.java

示例7: setupLoggers

import java.util.logging.Handler; //导入方法依赖的package包/类
/**
 * Sets up loggers to print to stdout (rather than stderr) and log to ~/Shuffleboard/shuffleboard.log
 */
private void setupLoggers() throws IOException {
  //Set up the global level logger. This handles IO for all loggers.
  final Logger globalLogger = LogManager.getLogManager().getLogger("");

  // Remove the default handlers that stream to System.err
  for (Handler handler : globalLogger.getHandlers()) {
    globalLogger.removeHandler(handler);
  }

  final Handler fileHandler = new FileHandler(Storage.getStorageDir() + "/shuffleboard.log");

  fileHandler.setLevel(Level.INFO);    // Only log INFO and above to disk
  globalLogger.setLevel(Level.CONFIG); // Log CONFIG and higher

  // We need to stream to System.out instead of System.err
  final StreamHandler sh = new StreamHandler(System.out, new SimpleFormatter()) {
    @Override
    public synchronized void publish(final LogRecord record) { // NOPMD this is the same signature as the superclass
      super.publish(record);
      // For some reason this doesn't happen automatically.
      // This will ensure we get all of the logs printed to the console immediately instead of at shutdown
      flush();
    }
  };
  sh.setLevel(Level.CONFIG); // Log CONFIG and higher to stdout

  globalLogger.addHandler(sh);
  globalLogger.addHandler(fileHandler);
  fileHandler.setFormatter(new SimpleFormatter()); //log in text, not xml

  globalLogger.config("Configuration done."); //Log that we are done setting up the logger
  globalLogger.config("Shuffleboard app version: " + Shuffleboard.class.getPackage().getImplementationVersion());
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:37,代码来源:Shuffleboard.java

示例8: enableLogging

import java.util.logging.Handler; //导入方法依赖的package包/类
public static void enableLogging() {
    Logger logger = Logger.getLogger(com.sun.tools.javac.Main.class.getPackage().getName());
    logger.setLevel(Level.ALL);
    for (Handler h : logger.getParent().getHandlers()) {
        h.setLevel(Level.ALL);
    }

}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:9,代码来源:JavaCompiler.java

示例9: getLogger

import java.util.logging.Handler; //导入方法依赖的package包/类
private static Logger getLogger() {
	Logger result = Logger.getAnonymousLogger();
	result.setLevel(Level.ALL);
	result.setUseParentHandlers(false);
	Handler handler = new FlushedStreamHandler(System.err, new StandardFormatter());
	handler.setLevel(Level.ALL);
	result.addHandler(handler);
	return result;
}
 
开发者ID:Bibliome,项目名称:bibliome-java-utils,代码行数:10,代码来源:BuildDictionary.java

示例10: setRootLoggerLevel

import java.util.logging.Handler; //导入方法依赖的package包/类
/**
 * Overrides the system's root logger level.
 * <p>
 * This is for internal testing and debugging only!
 *
 * @param level the level to use, not null
 */
@Nonnull
public static void setRootLoggerLevel(@Nonnull Level level) {
  Objects.requireNonNull(level);

  Logger rootLogger = Logger.getLogger("");

  for (Handler handler : rootLogger.getHandlers())
    handler.setLevel(Level.FINEST);

  rootLogger.setLevel(level);
}
 
开发者ID:lokalized,项目名称:lokalized-java,代码行数:19,代码来源:LoggingUtils.java

示例11: main

import java.util.logging.Handler; //导入方法依赖的package包/类
public static void main(String[] args) {
    TestInferCaller test = new TestInferCaller();
    Logger root = Logger.getLogger("");
    for (Handler h : root.getHandlers()) {
        h.setLevel(Level.OFF);
    }
    root.addHandler(new TestHandler());

    for (Logger logger : Arrays.asList(root, Logger.getGlobal(),
            Logger.getAnonymousLogger(), Logger.getLogger("foo.bar"))) {
        System.out.println("Testing with: " + loggerName(logger) + " " + logger.getClass());
        test.test(logger);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:TestInferCaller.java

示例12: setLevel

import java.util.logging.Handler; //导入方法依赖的package包/类
private static void setLevel(Logger pLogger, Level pLevel) {
    Handler[] handlers = pLogger.getHandlers();
    for (Handler h : handlers) {
        h.setLevel(pLevel);
    }
    pLogger.setLevel(pLevel);
}
 
开发者ID:openaudible,项目名称:openaudible,代码行数:8,代码来源:AudibleClient.java

示例13: onApplicationEvent

import java.util.logging.Handler; //导入方法依赖的package包/类
@Override
public void onApplicationEvent(ApplicationEvent event) {
    if (event instanceof ContextRefreshedEvent) {
		Logger log = LogManager.getLogManager().getLogger("");
		for (Handler h : log.getHandlers()) {
		    h.setLevel(Level.INFO);
		}        	
    }
}
 
开发者ID:guilhebl,项目名称:item-shop-reactive-backend,代码行数:10,代码来源:ApplicationListenerBean.java

示例14: setJDKDebugEnabled

import java.util.logging.Handler; //导入方法依赖的package包/类
/**
 * 开启DEBUG级别日志(仅针对JDK14LOGGER,LOG4J请自行修改配置文件)
 * 
 * @param isEnabled
 */
public static void setJDKDebugEnabled(Boolean isEnabled) {
    //如果使用JDK14LOGGER,将业务日志级别设为DEBUG(FINE)
    if (blog instanceof Jdk14Logger) {
        Jdk14Logger logger = (Jdk14Logger) blog;
        if (isEnabled) {
            logger.getLogger().setLevel(Level.FINE);
            Handler consoleHandler = new ConsoleHandler();
            consoleHandler.setLevel(Level.FINE);
            logger.getLogger().addHandler(consoleHandler);
        } else {
            logger.getLogger().setLevel(Level.INFO);
        }
    }
}
 
开发者ID:wendal,项目名称:alipay-sdk,代码行数:20,代码来源:AlipayLogger.java

示例15: setJDKDebugEnabled

import java.util.logging.Handler; //导入方法依赖的package包/类
public static void setJDKDebugEnabled(Boolean isEnabled) {
    //如果使用JDK14LOGGER,将业务日志级别设为DEBUG(FINE)
    if (blog instanceof Jdk14Logger) {
        Jdk14Logger logger = (Jdk14Logger) blog;
        if (isEnabled) {
            logger.getLogger().setLevel(Level.FINE);
            Handler consoleHandler = new ConsoleHandler();
            consoleHandler.setLevel(Level.FINE);
            logger.getLogger().addHandler(consoleHandler);
        } else {
            logger.getLogger().setLevel(Level.INFO);
        }
    }
}
 
开发者ID:1991wangliang,项目名称:pay,代码行数:15,代码来源:AlipayLogger.java


注:本文中的java.util.logging.Handler.setLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。