Skip to content

Instantly share code, notes, and snippets.

@tomoTaka01
Last active December 19, 2015 03:18
Show Gist options
  • Save tomoTaka01/5889009 to your computer and use it in GitHub Desktop.
Save tomoTaka01/5889009 to your computer and use it in GitHub Desktop.
Logging sample(JDK8)
import java.util.concurrent.FutureTask;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
public class LogSample {
private static final Logger logger = Logger.getLogger(LogSample.class.getName());
public static void main(String[] args) {
logger.setLevel(Level.ALL);
logger.setUseParentHandlers(false);
ConsoleHandler ch = new ConsoleHandler();
ch.setLevel(Level.ALL);
logger.addHandler(ch);
new FutureTask<>(() -> {
logger.log(Level.SEVERE, "log severe");
logger.log(Level.WARNING, "log warning");
logger.log(Level.INFO, "log info");
logger.log(Level.CONFIG, "log config");
logger.log(Level.FINE, "log fine");
logger.log(Level.FINER, "log finer");
logger.log(Level.FINEST, "log finest");
}, null).run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment