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);
}
}
}
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;
}
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();
}
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();
}
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);
}
Aggregations