如何更改Weblogic 10/11的日志格式?
我想更改Weblogic服务器日志的日志格式。现在它正在使用默认格式生成日志——我希望能够指定我自己的格式。
例如,它生成如下所示的日志:
####<Jan 21, 2010 3:24:24 PM EST> <Info> <Socket> <FS2LOANER-00981> <DPSCoreServer1> <[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1264105464314> <BEA-000436> <Allocating 2 reader threads.>
####<Jan 21, 2010 3:24:24 PM EST> <Info> <Socket> <FS2LOANER-00981> <DPSCoreServer1> <[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1264105464314> <BEA-000446> <Native IO Enabled.>
我尝试通过让 Weblogic 使用 LOG4J 作为其日志记录系统并让它使用定义我所需日志格式的 log4j.properties 文件来修改日志格式。但是,无论我尝试什么,weblogic 都不会获取我的 log4j.property 文件设置并继续以其所需的格式进行登录。
这实际上是与以下帖子非常相似的问题,但该问题从未真正得到解答(批准的答案是关于如何打开 log4j 调试,这并没有帮助我弄清楚为什么 weblogic 没有获取我的 log4j.properties文件)。 在 weblogic 9/10 中使用 log4j 日志记录
I want to change the log format for Weblogic's server log. Right now it's generating logs using its default format-- I want to be able to specify my own format.
For example, it generates logs that look like this:
####<Jan 21, 2010 3:24:24 PM EST> <Info> <Socket> <FS2LOANER-00981> <DPSCoreServer1> <[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1264105464314> <BEA-000436> <Allocating 2 reader threads.>
####<Jan 21, 2010 3:24:24 PM EST> <Info> <Socket> <FS2LOANER-00981> <DPSCoreServer1> <[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1264105464314> <BEA-000446> <Native IO Enabled.>
I have tried to modify the log format by having Weblogic use LOG4J as its logging system and having it use my log4j.properties file which defines my desired log formats. However, weblogic does not pick up my log4j.property file settings and continues to log in its desired format, regardless of what I try.
This is effectively a very similar question to the following post, but that question never really got answered (the approved answer was regarding how to turn on log4j debugging, which hasn't helped me figure out why weblogic is not picking up my log4j.properties file). Using log4j logging in weblogic 9/10
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
创建域启动类如下:
Amnon
Create a domain startup class as follows:
Amnon
据我所知,您不能(不,您不想)更改WebLogic Server自己的日志消息格式(支持人员将非常乐意在出现问题时提供所需的信息)。
但您可以将 WebLogic 配置为使用 Log4j(请参阅 如何将 Log4j 与 WebLogic 日志记录服务结合使用),并且当启用 Log4j 时,您可以获得对服务器正在使用的
org.apache.log4j.Logger
的引用并附加您自己的附加器。但这并不能替代WebLogic自己的日志。
To my knowledge, you can't (and no, you don't want to) change WebLogic Server's own Log Message Format (the support will be very happy to have the required informations in case of a problem).
But you can configure WebLogic to use Log4j (see How to Use Log4j with WebLogic Logging Services) and, when Log4j is enabled, you can get a reference to the
org.apache.log4j.Logger
that the server is using and attach your own appender.But this is not a replacement of WebLogic's own log.
我无意更换WebLogic的记录器,但我确实有非常强烈的愿望配置日志格式。 Amnon发布的方法效果很好(所以我不知道为什么你说你不能改变格式);我只是想要一些额外的细节。
我在该方法中看到的唯一负面影响是,如果您将 StdOut/StdErr 重定向到日志记录子系统,它会在日志中显示为 %c 转换字符的空值;如果我不改变布局模式,那么我会看到 和 。
这就是我想要看到的原始模式布局字符串,这样我就可以进行更改并保留在日志文件中。
I have no desire to replace WebLogic's logger, but I do have a very strong desire to configure the log format. The method Amnon posted works very well (so I'm not sure why you say you can't change the format); I'd just like some additional detail.
About the only negative I see with the method is that, if you have StdOut/StdErr redirected to the logging subsystem, it shows up in the log with an empty value for the %c conversion character; if I don't change the layout pattern then I see and instead.
That is what I wanted to see the original pattern layout string, so I could make my changes and keep in the logfile.
到目前为止的帖子没有回答最初的问题,这就是为什么 WebLogic 没有选择 log4j.properties 文件中配置的所需日志格式。
在我看来,您正在使用 WL 的服务器日志记录桥将应用程序的 log4j 消息重定向到 WL 服务器的日志记录服务?如果这个假设是正确的,来自配置日志文件和过滤日志Oracle WebLogic Server 的消息,您需要在 WL 服务器的启动命令中传递一个参数,以加载正确的 log4j 配置,
-Djava.util.logging.config.file=/[PATH]/log4j.properties
Cleaner 只需在启动 WL 时传递此 JVM 选项,不过您也可以像上一篇文章中那样通过编程来实现它。
The posts so far did not answer the original question, which is why WebLogic does not pick up the desired log format configured in log4j.properties file.
It sounds to me that you are using WL's Server Logging Bridge to redirect application's log4j's messages to the WL server's logging services? If this assumption is correct, from Configuring Log Files and Filtering Log Messages for Oracle WebLogic Server, you would need to pass an argument in the WL server's startup command, to load the correct log4j configurations,
-Djava.util.logging.config.file=/[PATH]/log4j.properties
Cleaner just pass this JVM option when you launch WL, though alternatively you can achieve it programmingly as in the previous post.
Weblogic 没有获取您的 log4j.properties,因为它不知道有一个。
您需要转到服务器的类路径并将路径附加到属性文件,保存更改并重新启动服务器。它应该可以解决问题。
Weblogic is not picking up your log4j.properties because its does not know that there is one.
You need to go to server's classpath and append the path to properties file, save changes and restart your server. It should do the trick.