# Turning logging on while fixtures load?

**URL:** <https://www.ruby-forum.com/t/turning-logging-on-while-fixtures-load/109634>\
**Category:** Rails\
**Created:** [July 17, 2007, 1:52pm UTC](https://www.ruby-forum.com/t/turning-logging-on-while-fixtures-load/109634 "2007-07-17T13:52:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hugh\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/d2c977/32.png) [@Hugh\_S](https://www.ruby-forum.com/u/Hugh_S)\
**Post date:** [July 17, 2007, 1:52pm UTC](https://www.ruby-forum.com/t/turning-logging-on-while-fixtures-load/109634/1 "2007-07-17T13:52:07Z")

</div>

How do I get maximal logging while fixtures load? Or at least during  
the  
tests?

I have added this to test/test\_helper.rb :-

def logger  
RAILS\_DEFAULT\_LOGGER.level = Logger::INFO  
RAILS\_DEFAULT\_LOGGER  
end

so that I can use logger.info(“message”) in my tests, This didn’t  
work, and neither did

# Replace this with your real tests.

# Leave this till other tests work

def test\_truth  
RAILS\_DEFAULT\_LOGGER.level = Logger::INFO  
RAILS\_DEFAULT\_LOGGER.debug(“studen\_test.test\_truth”)  
assert trueo  
end

I still get nothing logged when this runs. I’m trying to debug my  
fixtures which are setup with fixture\_references, but I can’t even  
get logging to work here. I’m looking for entries in the log directory  
where the {developer,test,server,production}.log files are, but nothing  
ends up in those, even though they exist.

` Thank you,  
Hugh

---

<div class="post-metadata">

**Author:** ![Hugh\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/d2c977/32.png) [@Hugh\_S](https://www.ruby-forum.com/u/Hugh_S)\
**Post date:** [July 19, 2007, 4:29pm UTC](https://www.ruby-forum.com/t/turning-logging-on-while-fixtures-load/109634/2 "2007-07-19T16:29:58Z")

</div>

On Jul 17, 12:51 pm, Hugh S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> How do I get maximal logging whilefixturesload? Or at least during the  
> tests?

Rails turns off logging while the fixtures are loading. To get output  
in the logs, you have to do a little hack of rails.

Firstly, it’s probably best to do this in a frozen version of rails,  
then you only affect your own app.

The edit needs to be done in vendor/rails/activerecord/lib/  
active\_record/fixtures.rb in the method self.create\_fixtures(…).  
Find the bit where it says  
ActiveRecord::Base.silence do  
…  
end  
and comment out the start and end lines of the block.

That should do the trick.

Rebecca

---

<div class="post-metadata">

**Author:** ![Hugh\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/d2c977/32.png) [@Hugh\_S](https://www.ruby-forum.com/u/Hugh_S)\
**Post date:** [July 20, 2007, 10:45am UTC](https://www.ruby-forum.com/t/turning-logging-on-while-fixtures-load/109634/3 "2007-07-20T10:45:17Z")

</div>

On Thu, 19 Jul 2007, Rebecca Blyth wrote:

> …  
> end  
> and comment out the start and end lines of the block.

Thank you. I would never have found that without help.

> That should do the trick.
> 
> Rebecca

```
    Thank you,
    Hugh
```
