在 Glassfish 3.0.1 中部署的 Web 应用程序中处理 slf4j 日志记录的好方法是什么?

发布于 2024-09-25 05:21:05 字数 703 浏览 2 评论 0原文

我有一个非常普通的 Web 应用程序,它使用 slf4j 进行日志记录,这很好,并且我使用了几个 slf4j 后端,没有任何问题。

在 Tomcat 下,我只是告诉 logback 指向文件系统中的某个位置并在那里进行日志记录,但现在我想在单个 Glassfish 3.0.1 实例的自己的域中部署该应用程序的多个独立实例,现在我发现我希望我的 slf4j 日志记录能够与 Glassfish 配合良好。

让 Glassfish 处理我的日志记录的好方法是什么(我敢说“最好”)。我应该使用 logback 将日志扁平化到 System.out 并让 Glassfish 处理控制台输出,还是有更好的标准方法来访问 Glassfish 内的记录器?


编辑:调查表明,GlassFish 3.0.1 既不提供 SLF4J API,也不提供默认配置的 JSP 页面可见的类中的绑定。

通过提供 slf4j-api-X.jar 和 slf4j-jdk14-X.jar,slf4j-logging 事件将转发到由 Glassfish 正确捕获的 java.util.logging(请参阅 http://docs.sun.com/app/docs/doc/820-7692/abluj ?l=en&a=view 了解详细信息)。

I have a quite ordinary web application which logs with slf4j, which is fine, and I have used several slf4j backends without any problems.

Under Tomcat I just told logback to point at a location in the filesystem and log there, but now I want to deploy several independent instances of this application each in its own domain in a single Glassfish 3.0.1 instance, and I have now found that I would like my slf4j logging to work well with Glassfish.

What would be a good way (dare I say "best") to have my logging taken care of by Glassfish. Should I just flatten my logs to System.out with logback and let Glassfish handle the console output, or is there a better, standard way to reach the loggers inside Glassfish?


EDIT: Investigation has shown that GlassFish 3.0.1 does not provide neither the SLF4J API or a binding in the classes visible to a JSP-page with default configuration.

By providing slf4j-api-X.jar and slf4j-jdk14-X.jar the slf4j-logging events are forwarded to java.util.logging which is captured properly by Glassfish (see http://docs.sun.com/app/docs/doc/820-7692/abluj?l=en&a=view for details).

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

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

发布评论

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

评论(1

回忆凄美了谁 2024-10-02 05:21:05

调查表明,GlassFish 3.0.1 既不提供 SLF4J API,也不提供默认配置的 JSP 页面可见的类中的绑定。

通过提供 slf4j-api-X.jar 和 slf4j-jdk14-X.jar,slf4j-logging 事件将转发到由 Glassfish 正确捕获的 java.util.logging(请参阅 http://docs.sun.com/app/docs/doc/820-7692/abluj ?l=en&a=view 了解详细信息)。

注意:Glassfish 日志记录不会捕获堆栈跟踪。

Investigation has shown that GlassFish 3.0.1 does not provide neither the SLF4J API or a binding in the classes visible to a JSP-page with default configuration.

By providing slf4j-api-X.jar and slf4j-jdk14-X.jar the slf4j-logging events are forwarded to java.util.logging which is captured properly by Glassfish (see http://docs.sun.com/app/docs/doc/820-7692/abluj?l=en&a=view for details).

Note: Glassfish logging does not capture stack traces.

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