分类: Java
2013-09-15 13:37:47
package org.apache.log4j;
public class Logger {
// Creation and retrieval methods:
public static Logger getRootLogger();
public static Logger getLogger(String name);
// printing methods:
public void debug(Object message);
public void info(Object message);
public void warn(Object message);
public void error(Object message);
public void fatal(Object message);
// generic printing method:
public void log(Level l, Object message);
}
|
Logger x = Logger.getLogger("wombat");
Logger y = Logger.getLogger("wombat");
|
PropertyConfigurator.configure("log4j.properties");
|
private static Logger log = Logger.getLogger("MyCLASS.class");
|
log.debug("it is the debug info");
|
import org.apache.log4j.Logger;
public class Test {
static Logger log= Logger.getLogger(Test.class);
public void log(){
log.debug("Debug info.");
log.info("Info info");
log.warn("Warn info");
log.error("Error info");
log.fatal("Fatal info");
}
public static void main(String[] args) {
Test test = new Test();
test.log();
}
}
|
log4j.rootLogger=info, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
|
log4j.rootLogger=info, stdout
|
log.debug("Debug info.");
|
log4j.appender.A=org.apache.log4j.ConsoleAppender
|