使用 Payara/Glassfish 记录标准输出

发布于 2025-01-12 13:01:15 字数 414 浏览 6 评论 0原文

J2ee 应用程序在标准输出上写入一些调试数据。它在 Payara 5.2 服务器上运行,该服务器配置为将标准流写入 domains/myDomain/log/myLogName.log 但我在那里找不到消息。我确信我可以使用旧版本的 Glassfish(可能是 4.1)读取日志中的这些消息,从那时起配置发生了一些变化,但显然当前的配置是正确的。我应该检查什么?这可能是一个错误吗?

更新 1

一个月后我仍然不知道为什么日志系统不工作。我将 domain.xml 与另一台服务器中的类似服务器进行了比较,其中日志记录按预期工作,没有发现任何相关差异。 所有发送到标准输出和标准错误的消息都会丢失。在 Server.log 文件中,我只能找到来自 Payara 服务器本身的消息,而没有找到来自它包含的应用程序的消息。

A J2ee application writes some debugging data on standard output. It runs on Payara 5.2 server which is configured to write standard streams to domains/myDomain/log/myLogName.log but I cannot find the messages there. I'm sure I could read those messages in the log with an old version of Glassfish (may be 4.1), the configuration changed a bit since then, but apparently the current one is correct. What should I check ? Could it be a bug ?

Update 1

After a month I still have no idea why the logging system is not working. I compared domain.xml with a similar one in another server where logging is working as expected and found no relevant differences.
All messages sent to standard output and standard error are lost. In the Server.log file I can only find messages from Payara server itself, nothing form the applications it contains.

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

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

发布评论

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

评论(2

肤浅与狂妄 2025-01-19 13:01:15

这种行为非常奇怪,Payara 没有记录 System.out 上打印的内容,而且这不是配置问题。一些应用程序正在该 Payara 服务器上运行,其中一个应用程序具有以下调试代码:

import com.fasterxml.jackson.databind;
...
ObjectMapper myMapper = new ObjectMapper();
myMapper.writeValue(System.out, myObject);

在方法 writeValue 的 API 描述中,有以下注释:

注意:这里方法不会显式关闭底层流;但是,此映射器使用的 JsonFactory 可能会根据其设置选择关闭流(默认情况下,当我们构造的 JsonGenerator 关闭时,它会尝试关闭它)。

因此 Payara 日志记录被该应用程序错误且意外地停止。
很容易理解,但不容易发现!

我什至不知道可以关闭System.out,这不是你故意做的事情。

The behavior was very weird, Payara was not logging what was printed on System.out, and it was not a configuration issue. Some applications are running on this Payara server and one of them has the following debugging code:

import com.fasterxml.jackson.databind;
...
ObjectMapper myMapper = new ObjectMapper();
myMapper.writeValue(System.out, myObject);

In the API description of method writeValue there is the following note:

Note: method does not close the underlying stream explicitly here; however, JsonFactory this mapper uses may choose to close the stream depending on its settings (by default, it will try to close it when JsonGenerator we construct is closed).

So Payara logging was erroneously and unexpectedly stopped by this application.
Easy to understand, not so easy to find out !

I didn't even know it was possible to close System.out, it is something you don't do by purpose.

魂牵梦绕锁你心扉 2025-01-19 13:01:15

如果您确实想在 payara 控制台日志上显示系统。您可以启用“记录标准流”,以便能够包含您想要在日志中看到的打印输出。

您可以在“配置”>>中看到此选项“服务器配置”>> “记录器设置”。通过启用它,您还可以看到应用程序服务器上的活动流。

检查此图片作为您的指南。
https://i.sstatic.net/hplv1.jpg

另外请注意启用它将在您的服务器上产生更多日志。所以从长远来看,它会消耗更多的存储空间。如果您想在应用程序服务器上调试某些内容,我建议启用它。

If you really want to display the System out on payara console logs. You could enable the "Logging Standard Streams" to be able to include print out you want to see on your logs.

You can see this options to "Configuration" >> "server-config" >> "Logger Settings". by enabling it you can see also the active streams on you application server.

check this image for your guide.
https://i.sstatic.net/hplv1.jpg

Also do take note that enabling it will produce a lot more logs on your server. So it will consume more storage in the long run. I suggest to enable it if you want to debug something on your application server.

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