Java by API/org.apache.commons.lang.time/Logging — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 14:15, 31 мая 2010
LogFactory: getLog(Class cls)
/*
The Log being used >>> org.apache.rumons.logging.impl.Jdk14Logger@a97b0b
Jun 10, 2006 1:37:28 PM LoggingTrial main
INFO: INFO TEST
Jun 10, 2006 1:37:29 PM LoggingTrial main
INFO: INFO TEST
java.lang.Exception: A DUMMY EXCEPTION
at LoggingTrial.main(LoggingTrial.java:9)
Jun 10, 2006 1:37:29 PM LoggingTrial main
WARNING: WARN TEST
Jun 10, 2006 1:37:29 PM LoggingTrial main
WARNING: WARN TEST
java.lang.Exception: A DUMMY EXCEPTION
at LoggingTrial.main(LoggingTrial.java:9)
Jun 10, 2006 1:37:29 PM LoggingTrial main
SEVERE: ERROR TEST
Jun 10, 2006 1:37:29 PM LoggingTrial main
SEVERE: ERROR TEST
java.lang.Exception: A DUMMY EXCEPTION
at LoggingTrial.main(LoggingTrial.java:9)
Jun 10, 2006 1:37:29 PM LoggingTrial main
SEVERE: FATAL TEST
Jun 10, 2006 1:37:29 PM LoggingTrial main
SEVERE: FATAL TEST
java.lang.Exception: A DUMMY EXCEPTION
at LoggingTrial.main(LoggingTrial.java:9)
*/
import org.apache.rumons.logging.Log;
import org.apache.rumons.logging.LogFactory;
public class LoggingTrial {
public static void main(String[] args) {
Log log = LogFactory.getLog(LoggingTrial.class);
System.out.println("The Log being used >>> " + log);
Exception e = new Exception("A DUMMY EXCEPTION");
if (log.isTraceEnabled()) {
log.trace("TRACE TEST");
log.trace("TRACE TEST", e);
}
if (log.isDebugEnabled()) {
log.debug("DEBUG TEST");
log.debug("DEBUG TEST", e);
}
if (log.isInfoEnabled()) {
log.info("INFO TEST");
log.info("INFO TEST", e);
}
if (log.isWarnEnabled()) {
log.warn("WARN TEST");
log.warn("WARN TEST", e);
}
if (log.isErrorEnabled()) {
log.error("ERROR TEST");
log.error("ERROR TEST", e);
}
if (log.isFatalEnabled()) {
log.fatal("FATAL TEST");
log.fatal("FATAL TEST", e);
}
}
}