在WebSphere下使用Log4j从Spring登录 [英] Logging from Spring using Log4j under WebSphere

查看:86
本文介绍了在WebSphere下使用Log4j从Spring登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WebSphere应用程序中使用log4j.我需要调试类org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor,所以我已经在log4j.xml文件中创建了记录器:

I'm using log4j in my WebSphere application. I need to debug class org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor, so I've created logger in my log4j.xml file:

<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:

I've created also commons-logging.properties in src/main/resources of the web project (in maven):

org.apache.commons.logging.Log = org.apache.commons.logging.impl.Log4JLogger

org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

但是,Spring没有使用log4j进行日志记录.我在调试文件中没有看到springframework日志,但是在控制台中可以看到其中的一些(INFO).因此,我假设Spring使用的apache commons日志不是使用log4j进行日志.

However, Spring is NOT logging using log4j. I see no springframework logs in my debug file, but I can see some of them (INFO) in the console. Therefore I assume, the apache commons logging used by Spring is NOT logging using log4j.

是否可以(以及如何)将Spring使用的日志记录重定向到WebSphere下的Log4j引擎?

Is it possible (and how) to redirect logging used by Spring to Log4j engine under WebSphere?

共享库中提供的WebSphere 7.0,Spring 3.1.2,log4j 1.2.6,commons-logging 1.1.

WebSphere 7.0, Spring 3.1.2, log4j 1.2.6, commons-logging 1.1 provided in shared library.

推荐答案

此技术可将JCL(包括Spring)日志记录路由到您的log4j配置仍然有效.

对于已经拥有slf4j的应用程序(Spring WebFlow的应用程序),

For the apps where we also have slf4j already (the Spring WebFlow ones), that can also be routed to your log4j configuration.

但是,如果您只想查看Spring日志信息,则可以通过控制台的Troubleshooting> Logs and Trace>服务器名> Change log level details来增加其对WebSphere自己的日志(SystemOut.log)的日志记录级别.

However, if you just want to see the Spring log information, you can increase its level of logging to WebSphere's own logs (SystemOut.log) via the console's Troubleshooting > Logs and Trace > server-name > Change log level details.

添加类似: org.springframework.ejb.access.*=fine的内容(用冒号分隔).

Add something like : org.springframework.ejb.access.*=fine (colon is the separator).

我不知道确切的WAS级别对应于什么,但是如果您扩展组件和组"区域以查看是什么,则跟踪"级别下会列出finefinerfinest.可用的.

I don't know what the exact WAS levels correspond to, but fine, finer, and finest are listed under the "Trace" levels if you expand the Components and Groups area just to see what is available.

(我认为您的特定Spring软件包未在此处列出并不重要,顺便说一句.我相信它仍然可以成功控制您的日志记录.)

(I don't think it matters that your particular Spring package is not listed under there, BTW. I believe it should still successfully control your logging.)

这篇关于在WebSphere下使用Log4j从Spring登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆