如何让OpenEJB使用slf4j?
任何人都可以给出一个 pom.xml
依赖项配置的示例,该配置将使 OpenEJB 使用 slf4j 日志记录,而不是 JCL (据我所知,这就是它现在使用的)。
Can anyone give an example of pom.xml
dependencies configuration that will make OpenEJB to use slf4j logging, instead of JCL (this is what it uses now, as I understand).
see also How to configure OpenEJB logging?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我们支持:
LogStreamFactory 可以通过将类名设置为
openejb.log.factory
系统属性的值来插入。请随意复制现有的实现之一并更新 JCL 或 SLF4J。如果您也有尝试其他事情的冲动,该项目总是接受新的提交者!
We have support for:
New implementations of LogStreamFactory can be plugged in by setting the class name as the value of
openejb.log.factory
system property.Feel free to copy one of the existing impls and update for either JCL or SLF4J. The project is always accepting new committers if you get the urge to hack on other things as well!
感谢大卫的指点,这实际上很容易。您只需要实现两个类:
- Slf4jLogStreamFactory
- Slf4jLogStream
然后设置你的工厂:
System.setProperty("openejb.log.factory", "de.glauche.Slf4jLogStreamFactory");
和 Slf4jLogStream:
有了这个,我可以通过 slf4j 在我的 logback 记录器中获得格式良好的所有输出:)
Thanks to David's pointers, this is actually quite easy. You only need to implement two clases:
- Slf4jLogStreamFactory
- Slf4jLogStream
then set your factory :
System.setProperty("openejb.log.factory", "de.glauche.Slf4jLogStreamFactory");
and the Slf4jLogStream:
With this i'm getting all output nicely formated in my logback logger via slf4j :)
这就是我使 OpenEJB 使用外部日志记录的方法:
也许可以将此系统属性移动到某些全局资源,例如
pom.xml
?This is how I made OpenEJB to use external logging:
Maybe it's possible to move this system property to some global resource, like
pom.xml
?如果您添加 API 和 JCL 依赖项,那么使用 SLF4J API 的日志记录将定向到默认的 JCL 日志。
这就是你想要的吗?或者您想使用其他后端进行日志记录吗?
If you add the API and JCL dependencies then your logging using the SLF4J API will get directed to the default JCL logs.
Is that what you want? Or do you want to use some other back end for the logging?
不是 Maven 专家,但根据我的理解,您想要这样:
如果 OpenEJB 不支持 JCL,那么添加该依赖项将毫无意义,因此请使用 JUL 或 Log4j。
您可以在 Maven 存储库 中找到更多详细信息。
如果您确实想使用 JCL 桥,请使用以下命令:
Not a Maven expert, but from my understanding, you want this:
If OpenEJB doesn't support JCL, it would be pointless to add that dependency, so go with JUL or Log4j.
You can find more details at Maven repository.
Just in case you really want to use JCL bridge, use this:
如果您通过 Maven 的 exec 插件执行,请尝试以下操作:
If you are executing via Maven's exec plugin, try this: