Example usage for java.util.logging Logger getFilter

List of usage examples for java.util.logging Logger getFilter

Introduction

In this page you can find the example usage for java.util.logging Logger getFilter.

Prototype

public Filter getFilter() 

Source Link

Document

Get the current filter for this Logger.

Usage

From source file:net.openhft.chronicle.logger.jul.JulTestBase.java

protected void testChronicleConfiguration(String testId, Class<? extends Handler> expectedHandlerType)
        throws IOException {

    setupLogManager(testId);//from   w  ww  .  j  a  va2 s.c o m
    Logger logger = Logger.getLogger(testId);

    assertEquals(Level.INFO, logger.getLevel());
    assertFalse(logger.getUseParentHandlers());
    assertNull(logger.getFilter());
    assertNotNull(logger.getHandlers());
    assertEquals(1, logger.getHandlers().length);

    assertTrue(logger.getHandlers()[0].getClass() == expectedHandlerType);
}

From source file:org.ebayopensource.turmeric.eclipse.core.logging.SOALogger.java

/**
 * If the tracing is enabled, then the logging level will be setup accordingly.
 *
 * @param clazz the clazz//w w  w. j  ava  2  s  .c o m
 * @return An instance of <code>LogManager</code>
 */
public static synchronized SOALogger getLogger(String clazz) {
    java.util.logging.LogManager manager = java.util.logging.LogManager.getLogManager();
    Logger result = manager.getLogger(clazz);
    if (result instanceof SOALogger) {
        return (SOALogger) result;
    } else if (result != null) {//there is an existing logger instance
        if (loggers.keySet().contains(clazz)) {
            return loggers.get(clazz);
        }
        SOALogger logger = new SOALogger(clazz);
        logger.setLevel(result.getLevel());
        logger.setFilter(result.getFilter());
        logger.setParent(result.getParent());
        logger.setUseParentHandlers(logger.getUseParentHandlers());
        loggers.put(clazz, logger);
        return logger;
    } else {//can not find a logger, so let's create one.
        result = new SOALogger(clazz);
    }

    manager.addLogger(result);
    SOALogger logger = (SOALogger) manager.getLogger(clazz);
    try {
        ISOALoggingSystemProvider logSystemProvider = SOALoggingSystemExtensionRegistry.getInstance()
                .getLoggingSystemIDProvider(PluginLogDelegateHandler.getBuildSystemName());
        if (logSystemProvider != null) {
            logSystemProvider.newLoggerCreated(logger);
        }
    } catch (Exception e) {
        //ignore the issue
        e.printStackTrace();
    }
    return logger;
}