在WebSphere上使用slf4j进行OpenJPA日志记录

编程入门 行业动态 更新时间:2024-10-25 05:11:15
本文介绍了在WebSphere上使用slf4j进行OpenJPA日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的Java EE 6应用程序使用带回送功能的slf4j作为记录框架. 现在,我想将OpenJpa的SQL跟踪添加到我的日志文件中. OpenJpa文档说,我可以为此使用参数:

My Java EE 6 application uses slf4j with logback as logging framework. Now I want to add the SQL traces of OpenJpa to my log files. The OpenJpa-Documentation says, I can use a parameter to this:

<property name="openjpa.Log" value="slf4j"/>

我将WebSphere Application Server v8.0.0.1用作Java EE容器.如果我将应用程序部署到服务器,则此参数不会更改任何内容.我可以在WebSphere Admin Console中更改日志级别,这可以正常工作.但是a不能绕过OpenJpa登录到我的slf4j框架.

I use the WebSphere Application Server v8.0.0.1 as Java EE container. If I deploy my application to the server, this parameter does not change anything. I can change log levels in WebSphere Admin Console and this works fine. But a cannot bypass the OpenJpa logging to my slf4j framework.

有人使用这样的配置并解决了问题吗?

Does anyone uses such configuration and solved the problem?

顺便说一句.我知道,InformationCenter-Article publib.boulder.ibm/infocenter/wasinfo/v8r0/index.jsp?topic=%2Fcom.ibm.websphere.nd.doc%2Finfo %2Fae%2Fae%2Ftejb_jpatroubleshoot.html 说,该参数将被忽略,但一切都应该可行,是吧?

Btw. I know, that the InformationCenter-Article publib.boulder.ibm/infocenter/wasinfo/v8r0/index.jsp?topic=%2Fcom.ibm.websphere.nd.doc%2Finfo%2Fae%2Fae%2Ftejb_jpatroubleshoot.html says, that the parameter will be ignored, but everything should be possible, eh?

推荐答案

我解决了.

有四件事要做:

  • 假设OpenJpa记录语句.这是通过persistence.xml中的属性条目完成的.
  • 说Slf4j,它也必须从JUL获取日志.这可以通过安装SLF4J的SLF4JBridgeHandler来完成.我通过在应用程序启动时调用的ServletContextListener安装了桥.
  • 配置Logback,使其不记录来自JUL的所有日志,而仅记录所需的日志.这是通过在logBack-test.xml中添加LevelChangePropagator来完成的.
  • 询问WebSphere TraceService将日志从OpenJPA传递到应用程序.这是WebSphere管理控制台中的设置
  • Say that OpenJpa logs the statements. That is done by the property entry in the persistence.xml.
  • Say Slf4j that it has to fetch the logs from JUL too. This can be done by installing the SLF4JBridgeHandler by SLF4J. I installed the bridge via a ServletContextListener which is called at application start.
  • Configure Logback that it does not log ALL logs from JUL but only the needed Logs. This is done by adding the LevelChangePropagator in the logBack-test.xml
  • Ask the WebSphere TraceService to hand down the logs from OpenJPA to the application. This is a setting in the WebSphere Administration Console
  • 更多推荐

    在WebSphere上使用slf4j进行OpenJPA日志记录

    本文发布于:2023-11-25 03:59:18,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1628230.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:日志   WebSphere   slf4j   OpenJPA

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!