Search in sources :

Example 66 with Logger

use of java.util.logging.Logger in project tomcat by apache.

the class Tomcat method setSilent.

/**
     * Controls if the loggers will be silenced or not.
     * @param silent    <code>true</code> sets the log level to WARN for the
     *                  loggers that log information on Tomcat start up. This
     *                  prevents the usual startup information being logged.
     *                  <code>false</code> sets the log level to the default
     *                  level of INFO.
     */
public void setSilent(boolean silent) {
    this.silent = silent;
    for (String s : silences) {
        Logger logger = Logger.getLogger(s);
        pinnedLoggers.put(s, logger);
        if (silent) {
            logger.setLevel(Level.WARNING);
        } else {
            logger.setLevel(Level.INFO);
        }
    }
}
Also used : Logger(java.util.logging.Logger)

Example 67 with Logger

use of java.util.logging.Logger in project GCViewer by chewiebug.

the class DataReaderFacade method loadModel.

/**
     * Loads a model from a given <code>gcResource</code> logging all exceptions that occur.
     *
     * @param gcResource where to find data to be parsed
     * @return instance of GCModel containing all information that was parsed
     * @throws DataReaderException if any exception occurred, it is logged and added as the cause
     * to this exception
     */
public GCModel loadModel(GCResource gcResource) throws DataReaderException {
    if (gcResource == null) {
        throw new NullPointerException("gcResource must never be null");
    }
    if (gcResource instanceof GcResourceSeries) {
        return loadModelFromSeries((GcResourceSeries) gcResource);
    }
    if (!(gcResource instanceof GcResourceFile))
        throw new UnsupportedOperationException("Only supported for files!");
    DataReaderException dataReaderException = new DataReaderException();
    GCModel model = null;
    Logger logger = gcResource.getLogger();
    try {
        logger.info("GCViewer version " + BuildInfoReader.getVersion() + " (" + BuildInfoReader.getBuildDate() + ")");
        model = readModel((GcResourceFile) gcResource);
    } catch (RuntimeException | IOException e) {
        dataReaderException.initCause(e);
        logger.warning(LocalisationHelper.getString("fileopen_dialog_read_file_failed") + "\n" + e.toString() + " " + e.getLocalizedMessage());
    }
    if (dataReaderException.getCause() != null) {
        throw dataReaderException;
    }
    return model;
}
Also used : IOException(java.io.IOException) GcResourceFile(com.tagtraum.perf.gcviewer.model.GcResourceFile) Logger(java.util.logging.Logger) GcResourceSeries(com.tagtraum.perf.gcviewer.model.GcResourceSeries) GCModel(com.tagtraum.perf.gcviewer.model.GCModel)

Example 68 with Logger

use of java.util.logging.Logger in project feign by OpenFeign.

the class FallbackFactoryTest method defaultFallbackFactory_logsAtFineLevel.

@Test
public void defaultFallbackFactory_logsAtFineLevel() {
    server.enqueue(new MockResponse().setResponseCode(500));
    AtomicBoolean logged = new AtomicBoolean();
    Logger logger = new Logger("", null) {

        @Override
        public void log(Level level, String msg, Throwable thrown) {
            logged.set(true);
            assertThat(msg).isEqualTo("fallback due to: status 500 reading TestInterface#invoke()");
            assertThat(thrown).isInstanceOf(FeignException.class);
        }
    };
    logger.setLevel(Level.FINE);
    target(new FallbackFactory.Default<>(() -> "foo", logger)).invoke();
    assertThat(logged.get()).isTrue();
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Level(java.util.logging.Level) Logger(java.util.logging.Logger) Test(org.junit.Test)

Example 69 with Logger

use of java.util.logging.Logger in project feign by OpenFeign.

the class FallbackFactoryTest method defaultFallbackFactory_doesntLogByDefault.

@Test
public void defaultFallbackFactory_doesntLogByDefault() {
    server.enqueue(new MockResponse().setResponseCode(500));
    Logger logger = new Logger("", null) {

        @Override
        public void log(Level level, String msg, Throwable thrown) {
            throw new AssertionError("logged eventhough not FINE level");
        }
    };
    target(new FallbackFactory.Default<>(() -> "foo", logger)).invoke();
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) Level(java.util.logging.Level) Logger(java.util.logging.Logger) Test(org.junit.Test)

Example 70 with Logger

use of java.util.logging.Logger in project jmonkeyengine by jMonkeyEngine.

the class TestChatClient method main.

public static void main(String... args) throws Exception {
    // Increate the logging level for networking...
    System.out.println("Setting logging to max");
    Logger networkLog = Logger.getLogger("com.jme3.network");
    networkLog.setLevel(Level.FINEST);
    // And we have to tell JUL's handler also   
    // turn up logging in a very convoluted way
    Logger rootLog = Logger.getLogger("");
    if (rootLog.getHandlers().length > 0) {
        rootLog.getHandlers()[0].setLevel(Level.FINEST);
    }
    // Note: in JME 3.1 this is generally unnecessary as the server will
    // send a message with all server-registered classes.
    // TestChatServer.initializeClasses();
    // Leaving the call commented out to be illustrative regarding the
    // common old pattern.
    // Grab a host string from the user
    String s = getString(null, "Host Info", "Enter chat host:", "localhost");
    if (s == null) {
        System.out.println("User cancelled.");
        return;
    }
    // Register a shutdown hook to get a message on the console when the
    // app actually finishes
    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            System.out.println("Chat client is terminating.");
        }
    });
    TestChatClient test = new TestChatClient(s);
    test.setVisible(true);
}
Also used : Logger(java.util.logging.Logger)

Aggregations

Logger (java.util.logging.Logger)499 Test (org.junit.Test)70 LogRecord (java.util.logging.LogRecord)60 ActionReport (org.glassfish.api.ActionReport)56 Handler (java.util.logging.Handler)52 IOException (java.io.IOException)37 File (java.io.File)36 Level (java.util.logging.Level)25 ArrayList (java.util.ArrayList)22 ConsoleHandler (java.util.logging.ConsoleHandler)19 Properties (java.util.Properties)15 SimpleFormatter (java.util.logging.SimpleFormatter)15 Config (com.sun.enterprise.config.serverbeans.Config)14 HashMap (java.util.HashMap)14 Map (java.util.Map)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 ResourceBundle (java.util.ResourceBundle)11 LogManager (java.util.logging.LogManager)11 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)11 BlockingQueueHandler (fish.payara.nucleus.notification.BlockingQueueHandler)10