log4j与jboss

 

	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在哪里读取配置呢?

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值