快速业务通道

精通Grails: 在企业中使用Grails - 编程入门网

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-15
g.groovy 中一样。双击 ERROR 值并输入 TRACE,如图 6 所示:

图 7. 将根登录程序优先级从 ERROR 更改为 TRACE

为了验证控制台比以前更好用,在浏览器中,在 Grails 应用程序的主页上单击到 AirportMappingController 的链接。在大量新的输出中,您应该可以找到一些有关 Grails 如何导入初 始列表的详细信息。请参阅清单 8 中的样例:

清单 8. 增加 log4j 输出

[11277653] metaclass.RedirectDynamicMethod   Dynamic method [redirect] looking up URL mapping for   controller [airportMapping] and action [list] and   params [["action":"index", "controller":"airportMapping"]]   with [URL Mappings ------------ org.codehaus.groovy.grails.web.mapping.ResponseCodeUrlMapping@1bab0b /rest/airport/(*)? /(*)/(*)?/(*)? ] [11277653] metaclass.RedirectDynamicMethod Dynamic method   [redirect] mapped to URL [/trip/airportMapping/list] [11277653] metaclass.RedirectDynamicMethod Dynamic method   [redirect] forwarding request to [/trip/airportMapping/list] [11277653] metaclass.RedirectDynamicMethod Executing redirect   with response   [com.opensymphony.module.sitemesh.filter.PageResponseWrapper@19243f]

精通Grails: 在企业中使用Grails(7)

时间:2011-08-02 IBM Scott Davis

什么时候可以安全忽略 Fatal Error?

如果您曾经运行过 Grails 1.0.3,可能会注意到一条频繁出现在控制台输出中的奇怪错误 — [Fatal Error] :-1:-1: Premature end of file。大多数人仅仅是忽略它,因为它似乎真的不会引起任何错误( 不管致命与否)。

如果将登录级别转变为 trace,您就会看到有关致命错误的详细信息: converters.XMLParsingParameterCreationListener Error parsing incoming XML request: Error parsing XML。

正如大量冗长的日志输出所解释的那样,Grails 试图解析每个传入请求,把请求当作 XML。大多数请 求不是 XML,因此请求处理程序将根据实际情况报告错误,但仍然会正确地处理请求。

这个 “谎报军情的小 bug” 在版本 1.0.4 中得到了修复。

更改 log4j ConversionPattern

现在需要更改输出模式。在 Config.groovy 中,使用下面这一行设置模式: appender.''stdout.layout.ConversionPattern''=''[%r] %c{2} %m%n''。查看 log4j 文档,您决定将它设 置为更具描述性的东西。

单击 JConsole 中的 stdout MBean。将 conversionPattern 属性从它的原始值更改为 [%5p] %d {hh:mm:ss} (%F:%M:%L)%n%m%n%n。生成一些新的日志输出后,我将描述这些奇怪的符号的含义,了解设 置 conversionPattern 的更多信息)。

图 8. 在 PatternLayout 中更改 conversionPattern

现在再次在 Web 浏览器中单击主页链接和 AirportMappingController 链接。输出的格式发生了很大 变化,如清单 9 所示:

清单 9. 使用新的 conversionPattern 的控制台输出

[DEBUG] 09:04:47  (RedirectDynamicMethod.java:invoke:127) Dynamic method [redirect] looking up URL mapping for controller [airportMapping] and action [list] and params [["action":"index", "controller":"airportMapping"]] with [URL Mappings ------------ org.codehaus.groovy.grails.web.mapping.ResponseCodeUrlMapping@e73cb7 /rest/airport/(*)? /(*)/(*)?/(*)? ] [DEBUG] 09:04:47 (RedirectDynamicMethod.java:invoke:144) Dynamic method 

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号