Log: info(Object arg0, Throwable arg1) : Log « org.apache.commons.lang.time « Java by API






Log: info(Object arg0, Throwable arg1)

/*
The Log being used >>> org.apache.commons.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.commons.logging.Log;
import org.apache.commons.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);
    }
  }
}

           
       








Apache-Common-Lang.zip( 248 k)

Related examples in the same category

1.Log: debug(Object arg0)
2.Log: debug(Object arg0, Throwable arg1)
3.Log: error(Object obj, Throwable thr)
4.Log: error(Object obj)
5.Log: fatal(Object arg0)
6.Log: isDebugEnabled()
7.Log: isErrorEnabled()
8.Log: isFatalEnabled()
9.Log: isInfoEnabled()
10.Log: isTraceEnabled()
11.Log: isWarnEnabled()
12.Log: trace(Object obj)
13.Log: trace(Object arg0, Throwable arg1)
14.Log: warn(Object arg0)
15.Log: warn(Object arg0, Throwable arg1)