Skip to content

Instantly share code, notes, and snippets.

@tomoTaka01
Created June 29, 2013 00:05
Show Gist options
  • Save tomoTaka01/5889037 to your computer and use it in GitHub Desktop.
Save tomoTaka01/5889037 to your computer and use it in GitHub Desktop.
Log sample(by using JDK7)
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<Void>(new Runnable() {
@Override
public void run() {
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