# How can I exclude email texts from the log?

**URL:** <https://www.ruby-forum.com/t/how-can-i-exclude-email-texts-from-the-log/134815>\
**Category:** Rails\
**Created:** [April 15, 2008, 12:16pm UTC](https://www.ruby-forum.com/t/how-can-i-exclude-email-texts-from-the-log/134815 "2008-04-15T12:16:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@luma](https://www.ruby-forum.com/u/luma)\
**Post date:** [April 15, 2008, 12:16pm UTC](https://www.ruby-forum.com/t/how-can-i-exclude-email-texts-from-the-log/134815/1 "2008-04-15T12:16:19Z")

</div>

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](http://localhost:3000/login/login)

---

<div class="post-metadata">

**Author:** ![luma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@luma](https://www.ruby-forum.com/u/luma)\
**Post date:** [April 15, 2008, 12:36pm UTC](https://www.ruby-forum.com/t/how-can-i-exclude-email-texts-from-the-log/134815/2 "2008-04-15T12:36:23Z")

</div>

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](http://api.rubyonrails.org).

HTH,  
Bill

---

<div class="post-metadata">

**Author:** ![luma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@luma](https://www.ruby-forum.com/u/luma)\
**Post date:** [April 15, 2008, 1:03pm UTC](https://www.ruby-forum.com/t/how-can-i-exclude-email-texts-from-the-log/134815/3 "2008-04-15T13:03:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![luma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@luma](https://www.ruby-forum.com/u/luma)\
**Post date:** [April 15, 2008, 12:42pm UTC](https://www.ruby-forum.com/t/how-can-i-exclude-email-texts-from-the-log/134815/4 "2008-04-15T12:42:25Z")

</div>

> 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
