简体   繁体   English

关闭在 rails 中记录 base64 编码的附件

[英]Turn off logging base64 encoded attachment in rails

In my Rails project I send email with ActionMailer and add attachment (pdf file).在我的 Rails 项目中,我使用 ActionMailer 发送电子邮件并添加附件(pdf 文件)。 And when this email creating, in server log I see a loooooong (realy long - I can't scroll up to start) string - base64 encoded attachment.当这封电子邮件创建时,在服务器日志中我看到一个 loooooong(真的很长 - 我无法向上滚动开始)字符串 - base64 编码的附件。

Question: Can I turn off logging base64 encoded mails in my app?问题:我可以在我的应用程序中关闭记录 base64 编码的邮件吗?

First off, you can disable specific parts of your log like so:首先,您可以禁用日志的特定部分,如下所示:

Rails.application.config.filter_parameters += [
  :password,
  :encoded_key,
]

I believe :encoded_key is the big ActiveStorage one, but just look in your log to silence what you want.我相信:encoded_key是大的 ActiveStorage 之一,但只需查看您的日志即可使您想要的静音。

Another alternative is the fantastic LogRage gem.另一种选择是梦幻般的LogRage gem。 I personally use this for a lot of things, but it gives you very granular control over your logging.我个人将它用于很多事情,但它可以让您对日志进行非常精细的控制。 It also makes it easy to export logs to other services if you ever end up doing so in the future.如果您将来最终这样做,它还可以轻松地将日志导出到其他服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM