【发布时间】:2013-03-16 21:38:47
【问题描述】:
我们正准备尽快将我们的 JSF 2(MyFaces with Facelets 页面)应用程序迁移到生产环境。目前,我们的控制台日志(WebSphere v8 上的 SystemOut.log)充满了大量此类消息:
[3/26/13 16:42:33:744 CDT] 00000031 HtmlImageRend W Component UIGraphic Form:errorIconSave has no attribute alt or attribute resolves to null. Path to component {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /view/groupagreement/products/volumebased/VolumeBasedProducts.xhtml][Class: javax.faces.component.html.HtmlBody,Id: commonLayoutId][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id1364021679_785179b][Class: javax.faces.component.html.HtmlForm,Id: Form][Class: javax.faces.component.html.HtmlBody,Id: j_id363369746_1d362e8b][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id363369746_1d362e61][Class: org.richfaces.component.UIRegion,Id: j_id363369746_1d362e4a][Class: org.richfaces.component.UIPopupPanel,Id: confirmationPopUpForWayFinder][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id363369746_1d362ffd][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id363369746_1d362fbc][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id363369746_1d362f9a][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id363369746_1d362f70][Class: javax.faces.component.html.HtmlGraphicImage,Id: errorIconSave]}
[3/26/13 16:42:33:746 CDT] 00000031 HtmlResponseW W HTML nesting warning on closing div: element td rendered by component : {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /view/groupagreement/products/volumebased/VolumeBasedProducts.xhtml][Class: javax.faces.component.html.HtmlBody,Id: commonLayoutId][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id1364021679_785179b]} not explicitly closed
我们认为这种过多的日志记录可能会损害性能。虽然我们知道我们应该将我们的应用程序正确地编码为 html 规范,但它是由离岸供应商提供的,我们对代码质量没有我们想要的那样多的控制。此时我们可能没有时间修复所有的 xhtml 文件(将 alt 属性添加到图像等)。
有什么方法可以禁用此日志记录吗?例如 web.xml 上下文参数?我在 MyFaces 文档中找不到任何内容。
【问题讨论】:
-
我应该注意,我们使用 slf4j 和 log4j 实现。要控制 MyFaces 日志记录,我们是否需要根据 this myfaces question 中的一些答案将 java.util.logging 重定向到 slf4j?
-
经过进一步调查,SLF4J 的 jul-to-slf4j 桥似乎不是我们想要的,因为即使关闭日志语句也会影响性能。 (见performance note here)