EAR 中的 log4j 配置
我有一个由 ejb.jar 档案组成的 EAR。
我可以/应该将 log4j.xml 配置文件放置在 EAR 中的什么位置,以便为不同的 EJB 配置 log4j?
这是我的以下结构:
myEar
|-- myEjb1.jar
|-- myEjb2.jar
|-- myEjb3.jar
|-- lib
| -- myLib1.jar
| -- myLib2.jar
提前致谢!
I have an EAR composed of ejb.jar archives.
Where can / should I place my log4j.xml configuration file in my EAR in order to configure log4j for the different EJBs?
Here is my following structure:
myEar
|-- myEjb1.jar
|-- myEjb2.jar
|-- myEjb3.jar
|-- lib
| -- myLib1.jar
| -- myLib2.jar
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果log4j被ear中的不同模块使用,则应将其放在jar中,该jar位于ear的lib目录中。但这不是很方便,因为每次更改日志级别时,您都必须重新组装您的耳朵并重新部署它。
另一种选择是将 log4j 配置文件放置在该文件夹中,并将该文件夹添加到 Ear 的类路径中。大多数应用程序服务器都提供此功能(例如WebSphere)。它的便携性较差,但更易于管理:无需重新部署耳朵即可更改配置。
If log4j is used by different modules in the ear, it should be placed in a jar which is placed in the lib directory of the ear. But it is not very convenient since you will have to re-assemble your ear and redeploy it each time you change a log level.
Another option is to place the log4j config file in the folder and add that folder in the classpath of the ear. Most app server provides this feature (WebSphere for instance). It is less portable but more manageable: the config can be changed without redeploying the ear.
让我们澄清一下:您的企业应用程序只有一个 log4j,无论它由多少个EJB 组成。同样,只有一个配置文件。如果您需要为不同的 EJB 配置它,您的选择是在 EJB 代码中使用适当命名的记录器并在一个 log4j.xml 中管理它们。
Laurent 对于放置位置有一些有趣的建议 (+1)。
Let's straighten this out: there's only one log4j for your enterprise application, regardless of how many EJBs it consists of. Similarly, there's only one configuration file. If you need to configure it for different EJBs, your option is to use appropriately named loggers in EJB's code and manage them in one log4j.xml.
Laurent has some interesting advice on where to put it (+1).