[英]Ruby on Rails : Detailed error logs for a production environment
Whenever runnning in production, RoR displays only warnings and errors, which is fine. 每当在生产中运行时,RoR仅显示警告和错误,这很好。
Howver, the logger does not display detailed information about the error : no timestamp, no IP address, no user request. 但是,记录器不会显示有关该错误的详细信息:没有时间戳,没有IP地址,没有用户请求。
I tried creating a custom Logger, but it does not allow me to get the IP address and actual user request without using evil methods (since it's within a model). 我尝试创建一个自定义Logger,但是它不允许我在不使用恶意方法的情况下获得IP地址和实际用户请求(因为它在模型中)。
Ideally, I'd like to have messages such as : 理想情况下,我希望收到以下消息:
Started GET "/api/request?" for 89.80.x.x at Mon Nov 21 17:29:08 +0100 2011
And the strack trace of the error below. 和下面的错误的跟踪。 But these should only be displayed for warnings and errors, and the end user should not see them( so consider_all_requests_local should be off).
但是,这些仅应显示为警告和错误,并且最终用户不应看到它们(因此,应该关闭think_all_requests_local)。
Any way to achieve this ? 有什么办法可以做到这一点?
Exceptions in production mode should not happen often, so I went for this gem: Exception Notification . 生产模式下的异常不应经常发生,因此我选择了这个宝石: Exception Notification 。
An exception in production mode should be dealt with immediately so this is (for me at least) better then logging the error. 生产模式下的异常应立即处理,因此(至少对我来说)比记录错误要好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.