如何配置 OpenEJB 客户端日志记录?
我们正在使用连接到一个 OpenEJB 服务器容器的 OpenEJB 客户端。 OpenEJB 服务器由 Corosync 和 Pacemaker 管理,以实现故障转移操作。每当 OpenEJB 实例失败(由于网络、硬件、JVM 或其他问题引起)时,Corosync+Pacemaker 都会在另一台计算机中启动另一个 OpenEJB 服务器实例。该过程相对较快,因此这对于我们的用例来说不是问题。
虽然OpenEJB提供了原生的故障转移机制,但我们仍然选择用我们自己的机制来管理它,因为这样我们可以更好地控制客户端。除了过于冗长的客户端日志记录之外,一切都按预期工作。我们希望将其关闭或对其进行微调以禁用连接失败消息,例如:
22/08/2011 14:06:23 org.apache.openejb.client.StickyConnectionStrategy 连接 AVISO:故障转移:无法连接到服务器:ejbd://192.168.1.5:4201 异常:无法连接到服务器“ejbd://192.168.1.5:4201”。检查服务器是否已启动以及指定的 serverURL 是否正确。下一步尝试。
我已经尝试降低 OpenEJB 客户端中 log4j 的日志记录级别,但失败了。根据 log4j 文档 和 这篇文章应该是设置所需级别的问题“错误”或“致命”。那么问题来了,类目名称是什么?
我已经尝试过:
- p.put("log4j.category.OpenEJB.client", "error");
- p.put("log4j.category.OpenEJB", "错误");
但一切都没有改变。那么,我需要使用什么属性来关闭这些警告消息?
We are using OpenEJB clients that connect to one OpenEJB server container. The OpenEJB servers are managed by Corosync and Pacemaker for fail-over operation. Whenever an OpenEJB instance fails (caused by network, hardware, JVM or other problems) Corosync+Pacemaker starts another OpenEJB server instance in another machine. The process is relatively fast so that this is not a problem for our use cases.
Although OpenEJB provides a native fail-over mechanism, we still chose to manage it with our own mechanism, because that way we can better control the client. Everything is working as expected, except for the client logging that is too verbose. We would like to either turn it off or fine tune it in order to disable connection failure messages, such as this:
22/08/2011 14:06:23 org.apache.openejb.client.StickyConnectionStrategy connect
AVISO: Failover: Cannot connect to server(s): ejbd://192.168.1.5:4201 Exception: Cannot connect to server 'ejbd://192.168.1.5:4201'. Check that the server is started and that the specified serverURL is correct.. Trying next.
I've already tried to decrease the logging level for log4j in the OpenEJB client, but I failed. According to the log4j documentation and to this post it should be a matter of setting the desired level to "error" or "fatal". The question is, what is the category name?
I've already tried:
- p.put("log4j.category.OpenEJB.client", "error");
- p.put("log4j.category.OpenEJB", "error");
But nothing has changed. So, what property do I need to use to turn those WARN messages off?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
客户端使用 java.util.logging,因此应该可以通过与其连接的任何机制进行配置。
The client uses java.util.logging so should be configurable via whatever mechanism is hooked up to that.
只是为了将信息放在一起。为了控制 OpenEJB 客户端的日志记录机制,必须配置常规 Java Logger:
就是这样。
Just to put the information together. In order to control the logging mechanism for OpenEJB client one has to configure the regular Java Logger:
That's it.