使用WebSphere下的Log4j从Spring进行java日志记录
我在WebSphere应用程序中使用log4j。我需要调试类org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor
,所以我在log4j中创建了logger。xml文件:
<logger name="org.springframework">
<level value="INFO" />
</logger>
<logger name="org.springframework.ejb.access">
<level value="TRACE" />
</logger>
我还在web项目的src/main/resources(在maven中)中创建了commons-logging.properties
:
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
然而,Spring并没有使用log4j进行日志记录。我在调试文件中没有看到springframework日志,但我可以在控制台中看到其中一些日志(信息)。因此,我假设Spring使用的apache commons日志记录不是使用log4j
是否可能(以及如何)将Spring使用的日志重定向到WebSphere下的Log4j引擎
共享库中提供了WebSphere 7.0、Spring 3.1.2、log4j 1.2.6、commons logging 1.1
# 1 楼答案
尝试以下方法:
我希望现在一切顺利
# 2 楼答案
This technique to route JCL (including Spring) logging to your log4j configuration仍然有效
对于我们已经有slf4j的应用程序(Spring WebFlow应用程序),that can also be routed to your log4j configuration
但是,如果您只想查看Spring日志信息,可以通过控制台的
Troubleshooting
>;将其日志记录到WebSphere自己的日志(SystemOut.log)中Logs and Trace
>;服务器名称>Change log level details
添加
: org.springframework.ejb.access.*=fine
(冒号是分隔符)我不知道确切的WAS级别对应于什么,但是如果您展开Components and Groups区域只是为了查看可用的内容,那么
fine
、finer
和finest
将列在“跟踪”级别下(顺便说一句,我认为您的特定Spring软件包没有列在下面并不重要。我相信它仍然可以成功地控制您的日志记录。)