在WebSphere下使用Log4j从Spring进行日志记录[英] Logging from Spring using Log4j under WebSphere

本文是小编为大家收集整理的关于在WebSphere下使用Log4j从Spring进行日志记录的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

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

<logger name="org.springframework">
    <level value="INFO" />
</logger>

<logger name="org.springframework.ejb.access">
    <level value="TRACE" />
</logger>

我也创建了Web项目的SRC/Main/Main/Resources(在Maven中):

org.apache.commons.logging.log = org.apache.commons.logging.impl.log4jlogger

但是,弹簧没有使用log4j记录.我在调试文件中没有看到SpringFramework日志,但是我可以在控制台中看到其中的一些(信息).因此,我假设,春季使用的Apache Commons记录未使用Log4J记录.

是否有可能(以及如何)重定向春季使用的日志记录到WebSphere下的Log4J引擎?

WebSphere 7.0,Spring 3.1.2,Log4J 1.2.6,共享库中提供的Commons-Loging 1.1.

推荐答案

尝试以下内容:

  1. 考虑使用SLF4J进行记录.将log4j添加到Maven中的依赖项中.
  2. 将JCL-over-SLF4J添加到您的Maven依赖项中.这将每个请求从JCL重定向到SLF4J.
  3. 在Maven依赖项内搜索依赖性共享.排除它,因此不会到您的部署档案.
  4. 删除" commons-logging.properties" -file.

我希望现在每个人都可以.

其他推荐答案

这项技术可将JCL(包括Spring)登录到您的log4j配置仍然有效.

对于我们也已经拥有SLF4J(Spring WebFlow的)的应用程序,也可以路由到log4j配置.

但是,如果您只想查看弹簧日志信息,则可以通过控制台的Troubleshooting>> Logs and Trace> server-name> Change log level details将其记录级别提高到WebSphere自己的日志(Systemout.log)> .

添加: org.springframework.ejb.access.*=fine(结肠是分离器).

我不知道确切的级别对应于什么,但是如果您展开组件和组区域,则在"跟踪"级别下列出了fine,finer和finest可用的.

(我认为您的特定弹簧软件包在那儿没有列出.

本文地址:https://www.itbaoku.cn/post/1575086.html

问题描述

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>

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

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.

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 provided in shared library.

推荐答案

Try the following:

  1. Consider using slf4j for your logging. Add log4j to your dependencies in maven.
  2. Add jcl-over-slf4j to your maven dependencies. This redirectes each request from jcl to slf4j.
  3. Search for the dependency commons-logging inside your maven dependencies. Exclude it, so it does not get to your deployment archive.
  4. Delete the "commons-logging.properties"-file.

I hope that everythings works out fine now.

其他推荐答案

This technique to route JCL (including Spring) logging to your log4j configuration still works.

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

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.

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

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.

(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.)