具有多个 WebLogic 实例的 log4j

发布于 2024-09-07 03:46:37 字数 223 浏览 1 评论 0原文

我正在创建一个 Java Web 服务应用程序。我打算在集群中的每台机器上运行多个 WebLogic 实例。

我希望每个应用程序实例写入自己的日志文件,但我不确定如何在不创建特定于实例的 log4j 属性文件的情况下执行此操作。有什么方法可以让我动态确定 WebLogic 实例并将其附加到日志文件名中吗?有没有更好的方法来做到这一点,我还没有见过?

任何见解将不胜感激。谢谢!

莱昂

I'm creating a Java Web Services application. I intend to run multiple instances of WebLogic on each machine in a cluster.

I'd like each application instance to write to its own log file, but I'm not sure how to do so without creating instance specific log4j properties files. Is there some way for me to dynamically determine the WebLogic instance and append it to a log file name? Is there a better way to do this that I haven't seen?

Any insight would be greatly appreciated. Thanks!

Leon

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

茶底世界 2024-09-14 03:46:37

${weblogic.Name} 将为您提供 Weblogic 实例的名称。您可以将其用作 log4j 中文件名的一部分,如下所示。

log4j.appender.file.File=/<path>/myapplog_${weblogic.Name}.log

我们还在日志文件中使用此属性,如下所示

log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss.SSS} ${weblogic.Name} <myapp> [-] %-5p %m \: %c-(%L) %n

${weblogic.Name} will give you the name of the Weblogic instance. You can use this as part of the filename within log4j like below.

log4j.appender.file.File=/<path>/myapplog_${weblogic.Name}.log

We also use this attribute within the log file as below

log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss.SSS} ${weblogic.Name} <myapp> [-] %-5p %m \: %c-(%L) %n
深者入戏 2024-09-14 03:46:37

刚刚发现如果您使用 log4j2,则必须使用 ${sys:weblogic.Name}

Just found out that you have to use ${sys:weblogic.Name} if you are using log4j2.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文