关于jboss4.x的日志系统

本文介绍了一个基于ajax+hibernate+spring的项目在部署到jboss4.x时遇到的日志系统冲突问题及解决方法。作者最初尝试通过设置-Dlog4j.defaultInitOverride=true参数解决,但导致日志功能失效。最终通过移除war包lib中的log4j*.jar和common-logging.jar文件解决了冲突,并确保了日志系统的正常工作。
部署运行你感兴趣的模型镜像
本人有一个项目,是基于ajax+hibernate+spring的,在tomcat容器下面运行是日志系统没有任何问题,突然心血来潮,想把它移植到jboss4.x下面,为得是用spring集成ejb,不过在部署的时候就报下面的错误:
14:45:56,496 ERROR [STDERR] log4j:ERROR The class "org.apache.log4j.spi.ErrorHandler" was loaded by
14:45:56,496 ERROR [STDERR] log4j:ERROR [WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
java.net.FactoryURLClassLoader@172bab9
] whereas object of type
14:45:56,497 ERROR [STDERR] log4j:ERROR "org.jboss.logging.util.OnlyOnceErrorHandler" was loaded by
[org.jboss.system.server.NoAnnotationURLClassLoader@19616c7].
14:45:56,542 ERROR [STDERR] log4j:ERROR Could not create an Appender. Reported error follows.
14:45:56,542 ERROR [STDERR] java.lang.ClassCastException: org.jboss.logging.appender.DailyRollingFileAppender

    初看一下应该是日志系统的问题,上网查了下资料,没错,的确是日志的问题,查了下jboss论坛,看到有高手说只要在jboss启动是添加如下参数就可以解决错误:
   -Dlog4j.defaultInitOverride=true
   试了下,确实相关的Exception没有了,工程是能跑了,不过后来又发现一个问题,工程的相应日志系统也失灵了,汗。。。
   继续查资料,终于又发现了一篇帖子,只要jboss deploy下面相应的war lib中log4j*.jar和common-logging.jar删除就可以了,日志系统能正常运作了,jboss在日志方面(log4j和common-logging)有它自己的版本,如果你的web工程中有自己的日志系统,那么很容易与jboss的日志系统产生冲突,我现在都不用log4j了,直接用common-logging1.0.4(jboss默认应该就是这个版本),没必要自己再去配置日志系统。 

您可能感兴趣的与本文相关的镜像

GPT-oss:20b

GPT-oss:20b

图文对话
Gpt-oss

GPT OSS 是OpenAI 推出的重量级开放模型,面向强推理、智能体任务以及多样化开发场景

deploy/jbossweb-tomcat55.sar/server.xml <Valve className="org.apache.catalina.valves.FastCommonAccessLogValve" prefix="access_log." suffix=".log" pattern="%h %t %r %s %D" directory="${jboss.server.home.dir}/../output/logs" resolveHosts="false" /> http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html pattern配置: %a - Remote IP address %A - Local IP address %b - Bytes sent, excluding HTTP headers, or '-' if zero %B - Bytes sent, excluding HTTP headers %h - Remote host name (or IP address if resolveHosts is false) %H - Request protocol %l - Remote logical username from identd (always returns '-') %m - Request method (GET, POST, etc.) %p - Local port on which this request was received %q - Query string (prepended with a '?' if it exists) %r - First line of the request (method and request URI) %s - HTTP status code of the response %S - User session ID %t - Date and time, in Common Log Format %u - Remote user that was authenticated (if any), else '-' %U - Requested URL path %v - Local server name %D - Time taken to process the request, in millis %T - Time taken to process the request, in seconds %I - current request thread name (can compare later with stacktraces) There is also support to write information from the cookie, incoming header, outgoing response headers, the Session or something else in the ServletRequest. It is modeled after the apache syntax: %{xxx}i for incoming request headers %{xxx}o for outgoing response headers %{xxx}c for a specific request cookie %{xxx}r xxx is an attribute in the ServletRequest %{xxx}s xxx is an attribute in the HttpSession The shorthand pattern name common (which is also the default) corresponds to '%h %l %u %t "%r" %s %b'.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值