使用自己的 log4j 配置在 jboss 中部署的简单 EJB jar
我有一个带有无状态会话 bean 的简单 EJB jar,部署在 JBOSS AS 4.2.2 中的
下。从 jboss jmx 控制台查看,该 bean 注册在 JNDI 树下,我可以通过 JBOSS 外部的远程 java 客户端访问它。
在 EJB jar 内,我使用 apache log4j jar 和 log4j.xml 添加了一些要写入单独日志文件的日志记录。但我无法查看任何日志。
另外,我不希望使用 jboss-log4j.xml,因为将部署许多其他 EJB,并且希望为每个 EJB 应用程序拥有单独的 log4j。
这是我的 EJB-jar 内容之一:
EJB_DS.jar: log4j.xml apache log4j jar类
已添加到
路径。
请强调我是否遗漏了启用 log4j 配置的任何要点
I have a simple EJB jar with a stateless session bean, deployed in JBOSS AS 4.2.2, under <JBOSS_HOME>/server/default/deploy
. The bean is registered under JNDI tree as viewed from jboss jmx console and I am able to access it through a remote java client outside JBOSS.
Inside EJB jar, I have added some logging to be written to a separate log file, using apache log4j jar and log4j.xml. But I am not able to view any of the logs.
Also I do not wish to use jboss-log4j.xml, since there will be many other EJBs to be deployed and wish to have separate log4j for each EJB application.
Here is my one of the EJB-jar contents:
EJB_DS.jar:
log4j.xml
classes
apache log4j jar is added to <JBOSS_HOME>/server/default/lib
path.
Kindly highlight if i have missed any points for enabling log4j configuration
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,这在 JBoss 中不是一个选项。整个服务器运行单个 log4j 配置(由
conf/jboss-log4j.xml
指定),并且您的 EJB 无法更改它。这并不理想,但事实就是如此。另外,您不需要将
log4j.jar
添加到server/default/lib
,JBoss 已经有自己的内部副本。This isn't an option in JBoss, unfortunately. The entire server operates off a single log4j configuration (specified by
conf/jboss-log4j.xml
), and your EJBs cannot change that. It's not ideal, but that's the way it is.Also, you don't need to add
log4j.jar
toserver/default/lib
, JBoss already has its own internal copy.