Java Code Examples for java.util.logging.Logger.config()

The following are Jave code examples for showing how to use config() of the java.util.logging.Logger class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: jdk8u-jdk   File: TestIsLoggable.java   Source Code and License Vote up 6 votes
public void loglevel(Level l, Logger logger, String message) {
    LogTest test = LogTest.valueOf("LEV_"+l.getName());
    switch(test) {
        case LEV_SEVERE:
            logger.severe(message);
            break;
        case LEV_WARNING:
            logger.warning(message);
            break;
        case LEV_INFO:
            logger.info(message);
            break;
        case LEV_CONFIG:
            logger.config(message);
            break;
        case LEV_FINE:
            logger.fine(message);
            break;
        case LEV_FINER:
            logger.finer(message);
            break;
        case LEV_FINEST:
            logger.finest(message);
            break;
    }
}
 
Example 2
Project: openjdk-jdk10   File: TestIsLoggable.java   Source Code and License Vote up 6 votes
public void loglevel(Level l, Logger logger, String message) {
    LogTest test = LogTest.valueOf("LEV_"+l.getName());
    switch(test) {
        case LEV_SEVERE:
            logger.severe(message);
            break;
        case LEV_WARNING:
            logger.warning(message);
            break;
        case LEV_INFO:
            logger.info(message);
            break;
        case LEV_CONFIG:
            logger.config(message);
            break;
        case LEV_FINE:
            logger.fine(message);
            break;
        case LEV_FINER:
            logger.finer(message);
            break;
        case LEV_FINEST:
            logger.finest(message);
            break;
    }
}
 
Example 3
Project: alvisnlp   File: AbstractAlvisNLP.java   Source Code and License Vote up 5 votes
private File buildRootTempDir(Logger logger) throws IOException {
tmpDir.mkdirs();
       File result = File.createTempFile("alvisnlp", "", tmpDir);
       result.delete();
       result.mkdirs();
       logger.config("temporary directory: " + result.getCanonicalPath());
       return result;
   }
 
Example 4
Project: alvisnlp   File: AbstractAlvisNLP.java   Source Code and License Vote up 5 votes
@Override
public void setValue(Logger logger, PlanLoader<A> planLoader, Module<A> module) throws ParameterException, ConverterException, UnsupportedServiceException {
  		ParamHandler<A> h = module.getParamHandler(name);
	ParamConverter conv = converterFactory.getService(h.getType());
	conv.setInputDirs(inputDirs);
	conv.setOutputDir(outputDir);
	conv.setResourceBases(buildResourceBases());
	logger.config("setting " + h.getName() + " to '" + value + "' in " + module.getPath());
	h.setValue(conv.convert(value));
}
 
Example 5
Project: alvisnlp   File: AbstractAlvisNLP.java   Source Code and License Vote up 5 votes
@Override
public void setValue(Logger logger, PlanLoader<A> planLoader, Module<A> module) throws ParameterException, ConverterException, UnsupportedServiceException, SAXException, IOException, PlanException, URISyntaxException {
	logger.config("setting XML value to module " + module.getPath() + ": '" + xmlValue + "'");
  		InputSource is = new InputSource(new StringReader(xmlValue));
  		Document doc = XMLUtils.docBuilder.parse(is);
  		Element elt = doc.getDocumentElement();
  		planLoader.setParam(elt, module);
}
 
Example 6
Project: alvisnlp   File: AbstractAlvisNLP.java   Source Code and License Vote up 5 votes
private static void logEnvironment(Logger logger) {
	ResourceBundle res = ResourceBundle.getBundle("fr.inra.maiage.bibliome.alvisnlp.core.app.cli.LogEnvironment");
	for (String var : res.keySet()) {
		String value = System.getenv(var);
		if (value == null)
			continue;
		String label = res.getString(var);
		logger.config(label + ": " + value);
	}
}
 
Example 7
Project: shuffleboard   File: Shuffleboard.java   Source Code and License Vote up 5 votes
/**
 * 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());
}
 
Example 8
Project: incubator-netbeans   File: ActivatedDeativatedTest.java   Source Code and License Vote up 4 votes
public void activated(Logger uiLogger) {
    uiLogger.config("A started");
}
 
Example 9
Project: incubator-netbeans   File: ActivatedDeativatedTest.java   Source Code and License Vote up 4 votes
public void deactivated(Logger uiLogger) {
    uiLogger.config("D stopped");
}
 
Example 10
Project: alvisnlp   File: AbstractAlvisNLP.java   Source Code and License Vote up 4 votes
@Override
public void setValue(Logger logger, PlanLoader<A> planLoader, Module<A> module) throws Exception {
  		ParamHandler<A> h = module.getParamHandler(name);
	logger.config("unsetting " + h.getName() + " in " + module.getPath());
	h.setValue(null);
}
 
Example 11
Project: openjdk-jdk10   File: TestInferCaller.java   Source Code and License Vote up 4 votes
public void test1(Logger logger) {
    System.out.println("test1: " + loggerName(logger));

    AtomicInteger count = new AtomicInteger();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    logger.setLevel(Level.ALL);
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");

    logger.severe("message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    LogEvent event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test1", "message " + count.get());

    logger.warning("message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test1", "message " + count.get());

    logger.info("message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test1", "message " + count.get());

    logger.config("message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test1", "message " + count.get());

    logger.fine("message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test1", "message " + count.get());

    logger.finer("message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test1", "message " + count.get());

    logger.finest("message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test1", "message " + count.get());
}
 
Example 12
Project: openjdk-jdk10   File: TestInferCaller.java   Source Code and License Vote up 4 votes
public void test4(Logger logger) {
    System.out.println("test4: " + loggerName(logger));
    AtomicInteger count = new AtomicInteger();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    logger.setLevel(Level.ALL);
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");

    logger.severe(() -> "message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    LogEvent event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());

    logger.warning(() -> "message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());

    logger.info(() -> "message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());

    logger.config(() -> "message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());

    logger.fine(() -> "message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());

    logger.finer(() -> "message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());

    logger.finest(() -> "message " + count.incrementAndGet());
    assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
    event = TestHandler.PUBLISHED.remove();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());
}
 
Example 13
Project: alvisnlp   File: PlanLoader.java   Source Code and License Vote up 3 votes
/**
 * Reads plan description in the specified DOM tree and builds the corresponding module.
 * @param source
 * @return the sequence described in the specified DOM tree
 * @throws PlanException
 * @throws ConverterException 
 * @throws ServiceException 
 * @throws ParameterException 
 * @throws IOException 
 * @throws SAXException 
 * @throws URISyntaxException 
 */
public Sequence<T> loadDocument(Logger logger, String source, Document doc) throws PlanException, ModuleException, ServiceException, ConverterException, SAXException, IOException, URISyntaxException {
	logger.config("loading plan from " + source);
	Element elt = doc.getDocumentElement();
	if (!PLAN_ELEMENT_NAME.equals(elt.getTagName()))
		throw new PlanException("expected element " + PLAN_ELEMENT_NAME + ", got " + elt.getTagName());
	Sequence<T> result = loadSequence(logger, doc.getDocumentElement(), true);
	logger.fine("finished loading " + source);
	return result;
}