Created
June 29, 2013 00:05
-
-
Save tomoTaka01/5889037 to your computer and use it in GitHub Desktop.
Log sample(by using JDK7)
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 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