Soluation:
package com.dustbin.test;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
public class Sample {
static Logger logger=Logger.getLogger(Sample.class);
public static void main(String[] args) {
BasicConfigurator.configure();
logger.info("info message");
logger.warn("warn message");
logger.error("error message");
logger.fatal("fatal message");
logger.debug("debug msg");
}
}
Output:
0 [main] INFO
com.dustbin.test.Sample - info message
0 [main] WARN
com.dustbin.test.Sample - warn message
0 [main] ERROR
com.dustbin.test.Sample - error message
0 [main] FATAL
com.dustbin.test.Sample - fatal message
0 [main] DEBUG
com.dustbin.test.Sample - debug msg
Explanation:
Milliseconds thread
level fully qualified name -
message
%r %t % %c %m
0 comments:
Post a Comment