在 Weblogic 中初始化 log4j,在耳外
我无法想象我的问题是如此具体到我的情况,但到目前为止我没有看到这里提出任何类似的问题。
我希望能够在 .ear 包装之外指定一个 log4g.properties 文件,以便更轻松地更改日志记录级别,而无需重新包装 Ear。实际上,这样做的最紧迫动机是我们小组已经建立的约定,即将 log4j 属性文件放在耳朵之外,因此绕过该限制(通过将 log4j.properties 文件放在 APP-INF/classes 目录中) ,或耳根等)不适用。
Ear 包含一个无状态 EJB,它委托给一系列 Spring POJO 来完成其行为。
我见过我的小组中的其他人在 EAR 内部署 WAR 文件,其唯一的责任是使用上下文侦听器从指定的(外部)路径加载 log4j 属性文件。尽管该路径对于 EAR 来说是“外部”的,但它仍然位于类路径上。例如,文件夹 /config 位于类路径上,并且 WAR 使用上下文侦听器从 /config/appname/log4j.properties 加载 log4j.properties。
对我来说,使用 WAR 的唯一目的是加载 log4.properties 文件是一种 hack/overkill。
一定有更好的方法,对吧?
I can't imagine that my question is so specific to my case, but I did not see any similar questions asked here so far.
I would like to be able to specify a log4g.properties file outside of my .ear packaging so that it is easier to alter the logging levels without repackaging the ear. Actually, the most pressing motivation for doing it like that is our group's already-established convention of having the log4j properties files outside of the ear, so getting around that constraint (by putting the log4j.properties file in the APP-INF/classes dir, or the root of the ear, etc.) is not applicable.
The ear contains a stateless EJB that delegates to a series of Spring POJOs to accomplish its behavior.
I've seen others in my group deploy a WAR file inside the EAR with its only responsibility to load the log4j properties file from a specified (external) path using a context listener. Although the path is "external" to the EAR, it's still on the classpath. For example, the folder /config is on the classpath, and the WAR uses a context listener to load the log4j.properties from /config/appname/log4j.properties.
To me, using a WAR whose sole purpose is to load a log4.properties file is a hack/overkill.
There HAS to be a better way, right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将log4j.properties添加到weblogic的classpath中,并删除war和ear中的log4j.properties文件即可。
您可以在控制台中执行此操作。
转到服务器名称 - 配置 - 服务器启动
现在将 log4j.properties 目录添加到类路径中。
您的应用程序现在将使用您耳外的 log4j.properties 文件。
Just add log4j.properties to the classpath of weblogic and remove the log4j.properties file in the war and ear.
You can do this in the console.
Go to servername - configuration - Server Start
Now add the directory of log4j.properties to your classpath.
Your application now will use the log4j.properties file which is outside your ear.