Java .

Java Logging

java.util.Logging

TestLogging - Shows the basic usage of java.util.Logging

//new logging api in Java 1.4
import java.util.logging.*;

public class TestLogging { //set up a logger static Logger testLog = Logger.getLogger("Fluffycat.TestLog");

public static void main(String[] args) { //test a warning log testLog.warning("sample warning"); //test all priority levels to lowest //default will only show // SEVERE, WARNING, and INFO on your console testLog.log(Level.SEVERE, "severe log"); testLog.log(Level.WARNING, "warning log"); testLog.log(Level.INFO, "info log"); testLog.log(Level.CONFIG, "config log"); testLog.log(Level.FINE, "fine log"); testLog.log(Level.FINER, "finer log"); testLog.log(Level.FINEST, "finest log"); testLog.log(Level.ALL, "all log"); } }

References


Online
The Java 2 Platform Specification

Periodicals
"The Java Logging API" by Stuart Dabbs Halloway, June 2002, Vol 6 no 6, pp 32-37
Books
Thinking in Java by Bruce Eckel
Core Java (TM) 2 Volume 1 - Fundamentals by Cay Horstmann and Gary Cornell

Logging Output

May 14, 2002 10:33:18 AM TestLogging main
WARNING: sample warning
May 14, 2002 10:33:18 AM TestLogging main
SEVERE: severe log
May 14, 2002 10:33:18 AM TestLogging main
WARNING: warning log
May 14, 2002 10:33:18 AM TestLogging main
INFO: info log
Comments
Sign in to be the first to comment on Java Logging.