# Log Files in View

**URL:** <https://www.ruby-forum.com/t/log-files-in-view/74944>\
**Category:** Rails\
**Created:** [February 28, 2006, 9:34pm UTC](https://www.ruby-forum.com/t/log-files-in-view/74944 "2006-02-28T21:34:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_MacCaw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Alex\_MacCaw](https://www.ruby-forum.com/u/Alex_MacCaw)\
**Post date:** [February 28, 2006, 9:34pm UTC](https://www.ruby-forum.com/t/log-files-in-view/74944/1 "2006-02-28T21:34:55Z")

</div>

Is it possible to display the log files in the view?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Alex\_MacCaw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Alex\_MacCaw](https://www.ruby-forum.com/u/Alex_MacCaw)\
**Post date:** [March 1, 2006, 10:27am UTC](https://www.ruby-forum.com/t/log-files-in-view/74944/2 "2006-03-01T10:27:39Z")

</div>

Am Dienstag, den 28.02.2006, 21:34 +0100 schrieb Alex MacCaw:

> Is it possible to display the log files in the view?  
> Thanks in advance.

Rails views are ERB files and inside you can do anything what is doable  
with ruby.

If you want to display the current log file for example:

\<%= File.open(“#{RAILS\_ROOT}/log/#{RAILS\_ENV}.log”) { |f| f.read } %\>

–  
Norman T.

[http://blog.inlet-media.de](http://blog.inlet-media.de)

---

<div class="post-metadata">

**Author:** ![Alex\_MacCaw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Alex\_MacCaw](https://www.ruby-forum.com/u/Alex_MacCaw)\
**Post date:** [March 1, 2006, 5:40pm UTC](https://www.ruby-forum.com/t/log-files-in-view/74944/3 "2006-03-01T17:40:26Z")

</div>

Norman T. wrote:

> Am Dienstag, den 28.02.2006, 21:34 +0100 schrieb Alex MacCaw:
> 
> > Is it possible to display the log files in the view?  
> > Thanks in advance.
> 
> Rails views are ERB files and inside you can do anything what is doable  
> with ruby.
> 
> If you want to display the current log file for example:
> 
> \<%= File.open(“#{RAILS\_ROOT}/log/#{RAILS\_ENV}.log”) { |f| f.read } %\>
> 
> –  
> Norman T.
> 
> [http://blog.inlet-media.de](http://blog.inlet-media.de)

Thanks,  
Also what would be the commands to clear the log file?

---

<div class="post-metadata">

**Author:** ![Alex\_MacCaw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Alex\_MacCaw](https://www.ruby-forum.com/u/Alex_MacCaw)\
**Post date:** [March 1, 2006, 6:23pm UTC](https://www.ruby-forum.com/t/log-files-in-view/74944/4 "2006-03-01T18:23:31Z")

</div>

Am Mittwoch, den 01.03.2006, 17:40 +0100 schrieb Alex MacCaw:

> Also what would be the commands to clear the log file?

## File::truncate(“#{RAILS\_ROOT}/log/#{RAILS\_ENV}.log”, 0)

Norman T.

[http://blog.inlet-media.de](http://blog.inlet-media.de)

---

<div class="post-metadata">

**Author:** ![Alex\_MacCaw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Alex\_MacCaw](https://www.ruby-forum.com/u/Alex_MacCaw)\
**Post date:** [March 1, 2006, 6:29pm UTC](https://www.ruby-forum.com/t/log-files-in-view/74944/5 "2006-03-01T18:29:08Z")

</div>

Lee O’Mara wrote:

> Alex MacCaw wrote:
> 
> > Thanks,  
> > Also what would be the commands to clear the log file?
> 
> Now:
> 
> rake clear\_logs
> 
> Rails 1.1
> 
> rake logs:clear
> 
> –  
> Lee

Can you run this command inside a controller?

---

<div class="post-metadata">

**Author:** ![Alex\_MacCaw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Alex\_MacCaw](https://www.ruby-forum.com/u/Alex_MacCaw)\
**Post date:** [March 1, 2006, 6:25pm UTC](https://www.ruby-forum.com/t/log-files-in-view/74944/6 "2006-03-01T18:25:26Z")

</div>

Alex MacCaw wrote:

> Thanks,  
> Also what would be the commands to clear the log file?

Now:

rake clear\_logs

Rails 1.1

rake logs:clear

–  
Lee

---

<div class="post-metadata">

**Author:** ![Alex\_MacCaw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@Alex\_MacCaw](https://www.ruby-forum.com/u/Alex_MacCaw)\
**Post date:** [March 1, 2006, 7:31pm UTC](https://www.ruby-forum.com/t/log-files-in-view/74944/7 "2006-03-01T19:31:15Z")

</div>

Alex MacCaw wrote:

> > rake logs:clear
> 
> Can you run this command inside a controller?

No, those are Rake[1]tasks. They are run from the command line.

You can list all the available rake tasks for your app with: rake -T.

Geoffrey Grosenbach recently wrote up a nice piece about Rake and Rails  
[2]

1. [http://rake.rubyforge.org/](http://rake.rubyforge.org/)  
RAKE â?? Ruby Make

2. [http://nubyonrails.com/articles/2006/02/25/rake-rake-rake-your-boat](http://nubyonrails.com/articles/2006/02/25/rake-rake-rake-your-boat)  
rake, rake, rake your boat

–  
Lee
