public String testLog()
{
logger.debug("this is debug.");
logger.info("this is info.");
logger.warn("this is warn.");
logger.error("this is error.");
logger.fatal("this is fatal.");
System.out.println("System.out.println");
System.err.println("System.err.println");
return null;
}
测试1
将log4j的日志级别设为error,将jboss后台的日志级别设为info。
打印结果:
10:03:12,531 INFO [STDOUT] [-] ERROR 2010-08-27 10:03:12 this is error.
10:03:13,187 INFO [STDOUT] [-] FATAL 2010-08-27 10:03:13 this is fatal.
10:03:13,968 INFO [STDOUT] System.out.println
10:03:14,828 ERROR [STDERR] System.err.println
log4j中的info级别的日志没打印出来。
log4j打印的日志在jboss后台的日志级别中貌似都属于info级别。
测试2
将log4j的日志级别设为error,将jboss后台的日志级别设为error。
打印结果:
10:07:27,953 ERROR [STDERR] System.err.println
log4j的error、fatal级别的日志也没打印出来,而 System.err.println则打印出来了。
这里貌似也验证了log4j打印的日志在jboss后台的日志级别中貌似都属于info级别。
测试3
将log4j.properties配置文件删除,将jboss后台的日志级别设为info
打印结果:
10:11:12,765 INFO [STDOUT] 10:11:12,765 INFO [LogTestAction] this is info.
10:11:14,296 INFO [STDOUT] 10:11:14,296 WARN [LogTestAction] this is warn.
10:11:15,515 INFO [STDOUT] 10:11:15,515 ERROR [LogTestAction] this is error.
10:11:18,125 INFO [STDOUT] 10:11:18,125 FATAL [LogTestAction] this is fatal.
10:11:19,296 INFO [STDOUT] System.out.println
10:11:19,890 ERROR [STDERR] System.err.println
log4j的info级别的日志都打印出来了。
测试4
将log4j.properties配置文件删除,将jboss后台的日志级别设为error
打印结果:
10:16:04,500 ERROR [STDERR] System.err.println
log4j的日志都没有输出。
测试5
将log4j.properties配置文件删除,将jboss后台的日志级别设为warn
打印结果:
10:16:04,500 ERROR [STDERR] System.err.println
log4j的日志都没有输出。
测试6
将log4j.properties配置文件删除,将jboss后台的日志级别设为debug
打印结果:
10:22:43,187 INFO [STDOUT] 10:22:43,187 INFO [LogTestAction] this is info.
10:22:43,906 INFO [STDOUT] 10:22:43,890 WARN [LogTestAction] this is warn.
10:22:45,031 INFO [STDOUT] 10:22:45,031 ERROR [LogTestAction] this is error.
10:22:45,500 INFO [STDOUT] 10:22:45,500 FATAL [LogTestAction] this is fatal.
10:22:46,109 INFO [STDOUT] System.out.println
10:22:47,359 ERROR [STDERR] System.err.println
只打印了log4j日志级别info以上的日志。
这样能否说明,log4j的所有级别的日志,在jboss后台日志中的级别是info呢?
还有,删除了log4j.properties配置文件后,log4j在哪里读取配置呢?