I couldn't find the way to configure my dummy tutorial Grails application to log all HTTP requests and responses accepted/generated by Grails server (actually - Tomcat). Is this possible?
相关问题
- I want to trace logs using a Macro multi parameter
- Tomcat and SSL Client certificate
- Error message 'No handlers could be found for
- convert logback.xml to log4j.properties
- Django management command doesn't show logging
相关文章
- Tomcat的User信息可以存储到数据库中吗?
- tomcat的server.xml支持从Oracle中获取数据吗?
- web项目,Resonse Header发生解析错误,请大牛帮忙看看究竟是哪里的问题?
- Apache+Tomcat+JK实现的集群,如果Apache挂了,是不是整个服务就挂了?
- linux环境部署jpress,创建数据库时提提示连接失败
- how do I log requests and responses for debugging
- Making a two way SSL authentication between apache
- Android Studio doesn't display logs by package
Such logging could easily be implemented as a filter - either a Grails filter (see http://grails.org/doc/latest/guide/theWebLayer.html#filters for description of those and an example logging filter), or as a standard servlet filter (an example can be found here: http://www.java2s.com/Code/Java/Servlets/LogFilter.htm).
If you choose the second option, you'll have to modify
web.xml
to include your filter. To do so, executegrails install-templates
. This will copy standardweb.xml
totemplates/WEB-INF
directory in your project, and you can modify it there.Another option would be to use tomcat's built in access logging.
http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html#Access_Log_Valve
Im using this myself, and it is quite configurable.
How to configure tomcat 6
Add this to the end of your server.xml config under the tag "Host".
you could either use a Grails plugin: https://github.com/TouK/grails-httplogger or a Tomcat filter.
If you use Tomcat 7, it is the RequestDumperFilter. I prefer the RequestDumperFilter.
In short:
Install the Grails templates
Edit web.xml and add the RequestDumperFilter
Edit the log4j section in Config.groovy and add
This should be sufficient.
If you need some more information, here you will find an extensive instruction.