在 Glassfish 3.0.1 中部署的 Web 应用程序中处理 slf4j 日志记录的好方法是什么?
我有一个非常普通的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调查表明,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.