Created
June 29, 2013 00:03
-
-
Save tomoTaka01/5889026 to your computer and use it in GitHub Desktop.
Log Sample2(by using JDK8)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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