Skip to content

Instantly share code, notes, and snippets.

@tomoTaka01
Created June 29, 2013 00:03
Show Gist options
  • Save tomoTaka01/5889026 to your computer and use it in GitHub Desktop.
Save tomoTaka01/5889026 to your computer and use it in GitHub Desktop.
Log Sample2(by using JDK8)
import java.util.concurrent.FutureTask;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
public class LogSample2 {
private static final Logger logger = Logger.getLogger(LogSample.class.getName());
public static void main(String[] args) {
logger.setLevel(Level.INFO);
logger.setUseParentHandlers(false);
ConsoleHandler ch = new ConsoleHandler();
ch.setLevel(Level.INFO);
logger.addHandler(ch);
logger.log(Level.INFO, LogSample2.logInfo());
logger.log(Level.INFO, LogSample2.logInfo());
logger.log(Level.FINER, LogSample2.logFiner());
logger.log(Level.FINER, LogSample2::logFiner);
}
static String logInfo() {
System.out.println("*** called logInfo ***");
return "log info";
}
static String logFiner() {
System.out.println("*** called logFiner ***");
return "log finer";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment