Ruby Forum Ruby on Rails > how can I exclude email texts from the log?

Posted by Luma (Guest)
on 15.04.2008 12:16
(Received via mailing list)
hi

does anyone know how to prevent email texts to be written in the logs?
date, from, to, cc, bcc, subject, etc should stay in the log, only the
body to be excluded.

thanks

Luma




Processing LoginController#register (for 127.0.0.1 at 2008-04-04
23:30:25) [POST]
...

Sent mail:
 Date: Fri, 4 Apr 2008 23:30:27 +0200

From: ...

To: ...

Subject: ...

Mime-Version: 1.0

Content-Type: text/plain; charset=utf-8


... some quite long text ...


Redirected to http://localhost:3000/login/login
Posted by Bill Walton (Guest)
on 15.04.2008 12:36
(Received via mailing list)
Hi Luma,

Luma

> does anyone know how to prevent email texts
> to be written in the logs?

The filter_parameter_logging method should do what you need.  Something
like...

filter_parameter_logging { |k,v| v.replace '' if k == 'email_body'}

It lives in ActionController::Base at api.rubyonrails.org.

HTH,
Bill
Posted by Luma (Guest)
on 15.04.2008 12:42
(Received via mailing list)
> does anyone know how to prevent email texts to be written in the logs?
> date, from, to, cc, bcc, subject, etc should stay in the log, only the
> body to be excluded.


well, the logs also shouldn't contain email-attachments (which need
most space).

perhaps it will be easier to ban emails completely from the log files.
How can I do that?

Luma
Posted by Frederick Cheung (Guest)
on 15.04.2008 13:03
(Received via mailing list)
On 15 Apr 2008, at 11:41, Luma wrote:

>
> perhaps it will be easier to ban emails completely from the log files.
> How can I do that?
>
It's not super nice but we've got this in our production.rb:
config.action_mailer.logger = nil
>
Fred