# production.log is always empty

**URL:** <https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053>\
**Category:** rubyonrails-talk\
**Created:** [December 3, 2010, 4:45pm UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053 "2010-12-03T16:45:04Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [December 3, 2010, 4:45pm UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/1 "2010-12-03T16:45:04Z")

</div>

Hey all,

I can't help notice that while development.log always updates, production.log is completely empty. There's no runtime errors currently locally or on server. But in both cases, production.log is empty.

I tried solutions found on google, including the following:

• add config.log\_level = :info to config/environments/production.rb • uncomment config.log\_level = :debug in config/environments/production.rb

But that didn't do anything.

Also, speaking of production and development, why should you use both a production and development database (e.g. database\_development, database\_production) when both will contain the same fields? It seems like duplicate work.

Thanks for response.

---

<div class="post-metadata">

**Author:** ![Michael\_Pavling](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@Michael\_Pavling](https://discuss.rubyonrails.org/u/Michael_Pavling)\
**Post date:** [December 3, 2010, 5:07pm UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/2 "2010-12-03T17:07:35Z")

</div>

You don't mention what platform you're running on, but if it's \*nix, I would be inclined to check permissions. Does the account running the application have rights to write to the log folder and production.log file. Try deleting the file that's there and restarting the application to see if it gets recreated.

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [December 3, 2010, 5:12pm UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/3 "2010-12-03T17:12:22Z")

</div>

John Merlino wrote in post #965993:

> I can't help notice that while development.log always updates, production.log is completely empty. There's no runtime errors currently locally or on server. But in both cases, production.log is empty.

Are you sure your server is actually running in the production environment (RAILS\_ENV=production)?

> Also, speaking of production and development, why should you use both a production and development database (e.g. database\_development, database\_production) when both will contain the same fields? It seems like duplicate work.

There should be three databases at least. Development, test & production. It's not duplicate work migrations take care of moving the schema forward (at least for ActiveRecord).

Having separate development and production database allow you to experiment in the development database without affecting production data. The test database is there solely to support automated unit testing. This database should be emptied between each test case. You wouldn't want that to happen to the development or certainly not the production database.

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [December 3, 2010, 6:34pm UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/4 "2010-12-03T18:34:51Z")

</div>

> Are you sure your server is actually running in the production environment (RAILS\_ENV=production)?

I am not sure.

But on server, in: /etc/httpd/conf/rails.conf file

I have:

\<VirtualHost \*:80\> &nbsp;&nbsp;DocumentRoot /var/www/apps/human/public &nbsp;&nbsp;\<Directory /var/www/apps/human/public\> &nbsp;&nbsp;allow from all &nbsp;&nbsp;Options +Indexes &nbsp;&nbsp;\</Directory\> &nbsp;&nbsp;ServerName www.humandiet.net &nbsp;&nbsp;RailsEnv production \</VirtualHost\>

So this appears to be default by passenger.

In config/environment.rb I have this: ENV['RAILS\_ENV'] ||= 'production'

And my server has been restarted hundreds of times since those changes were made.

Thanks for response.

---

<div class="post-metadata">

**Author:** ![Colin\_Law1](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@Colin\_Law1](https://discuss.rubyonrails.org/u/Colin_Law1)\
**Post date:** [December 3, 2010, 7:56pm UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/5 "2010-12-03T19:56:34Z")

</div>

When you believe that you are running in production mode is development.log still getting written to? Each entry has a time stamp so it is easy to tell. If so then either you are actually running in development mode for some reason or the wrong log is getting written to.

Another thing you can do to check is in one of your views display the value of ENV['RAILS\_ENV'].

Colin

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [December 4, 2010, 1:50am UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/6 "2010-12-04T01:50:38Z")

</div>

When I try ENV['RAILS\_ENV'], it correctly says "production". But the production log is still not written to.

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [December 4, 2010, 1:58am UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/7 "2010-12-04T01:58:57Z")

</div>

> You don't mention what platform you're running on, but if it's \*nix, I would be inclined to check permissions. Does the account running the application have rights to write to the log folder and production.log file.

Using macbook pro, and users do have permission to read and write to the file. So I don't think that could be problem.

---

<div class="post-metadata">

**Author:** ![hassan](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/hassan/32/714_2.png) [@hassan](https://discuss.rubyonrails.org/u/hassan)\
**Post date:** [December 4, 2010, 2:03am UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/8 "2010-12-04T02:03:26Z")

</div>

> When I try ENV['RAILS\_ENV'], it correctly says "production". But the production log is still not written to.

Open a console in production mode and

> > RAILS\_DEFAULT\_LOGGER.info("what the hey")

=\> "2010-12-03-18:00:00 INFO what the hey\n"

> >

and then check the log file(s). Does that show up anywhere?

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [December 4, 2010, 2:29am UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/9 "2010-12-04T02:29:53Z")

</div>

> Open a console in production mode and
> 
> > > RAILS\_DEFAULT\_LOGGER.info("what the hey")
> 
> =\> "2010-12-03-18:00:00 INFO what the hey\n"
> 
> > >
> 
> and then check the log file(s). Does that show up anywhere?

I try it and still the production.log is empty:

[root@Proxima MARKT]# script/console production Loading production environment (Rails 2.3.8)

> > RAILS\_DEFAULT\_LOGGER.info("what the hey")

=\> "what the hey\n"

> > exit

[root@Proxima MARKT]# ls app config db doc IDENTIFIED lib log public Rakefile README script test tmp vendor [root@Proxima MARKT]# cd log [root@Proxima log]# ls development.log production.log server.log test.log [root@Proxima log]# nano production.log

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [December 4, 2010, 3:27am UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/10 "2010-12-04T03:27:23Z")

</div>

> There should be three databases at least. Development, test & production. It's not duplicate work migrations take care of moving the schema forward (at least for ActiveRecord).

I tried the migration with it:

MacBook-Pro:MARKT jmerlino$ rake db:migrate RAILS\_ENV=production (in /Users/jmerlino/MARKT ) rake aborted! Access denied for user 'root'@'localhost' (using password: YES)

This happens despite having a real simple password of only letters.

My database.yml file has this for production:

production: &nbsp;&nbsp;adapter: mysql &nbsp;&nbsp;encoding: utf8 &nbsp;&nbsp;database: website\_production &nbsp;&nbsp;host: localhost &nbsp;&nbsp;username: root &nbsp;&nbsp;password: mymysql

Also, I can access mysql via command line:

mysql -u root website\_development --password=mymysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 581 Server version: 5.1.40 MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

So I'm not sure why I get rake aborted error.

Thanks for response.

---

<div class="post-metadata">

**Author:** ![hassan](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/hassan/32/714_2.png) [@hassan](https://discuss.rubyonrails.org/u/hassan)\
**Post date:** [December 4, 2010, 4:04am UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/11 "2010-12-04T04:04:08Z")

</div>

> > and then check the log file(s). Does that show up anywhere?
> 
> I try it and still the production.log is empty:

Not the question -- did it show up \*anywhere\*? In another log?

> [root@Proxima log]# ls

I find it useful to &nbsp;&nbsp;alias newest='ls -alFGht | head -10'

Just a suggestion.

---

<div class="post-metadata">

**Author:** ![hassan](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/hassan/32/714_2.png) [@hassan](https://discuss.rubyonrails.org/u/hassan)\
**Post date:** [December 4, 2010, 4:38am UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/12 "2010-12-04T04:38:20Z")

</div>

Wait, what? You previously said:

[root@Proxima MARKT]# script/console production

You're definitely making this more complicated by switching back and forth between yourself and root -- an unnecessary variable.

---

<div class="post-metadata">

**Author:** ![Michael\_Pavling](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@Michael\_Pavling](https://discuss.rubyonrails.org/u/Michael_Pavling)\
**Post date:** [December 4, 2010, 6:40am UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/13 "2010-12-04T06:40:01Z")

</div>

Did you delete the production.log? Did it get recreated when you started the application?

---

<div class="post-metadata">

**Author:** ![Colin\_Law1](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@Colin\_Law1](https://discuss.rubyonrails.org/u/Colin_Law1)\
**Post date:** [December 4, 2010, 9:39am UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/14 "2010-12-04T09:39:32Z")

</div>

Please remember to quote the previous message so that your reply has some sort of context. Insert your reply into previous email. Thanks.

> When I try ENV['RAILS\_ENV'], it correctly says "production". But the production log is still not written to.

Inserting your reply inline also makes it more likely that all issues in previous post will be addressed. You have said that the production log is not written to but you have not answered my previous question: When you believe that you are running in production mode is development.log still getting written to? Or any other log for that matter.

Colin

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [December 6, 2010, 2:48pm UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/15 "2010-12-06T14:48:12Z")

</div>

> Inserting your reply inline also makes it more likely that all issues in previous post will be addressed. You have said that the production log is not written to but you have not answered my previous question: When you believe that you are running in production mode is development.log still getting written to? Or any other log for that matter.
> 
> Colin

No other log is getting written to. The only time a log is written to is the development log when I am running the app locally:

Processing DashboardsController#index (for 127.0.0.1 at 2010-12-06 09:30:04) [GET] &nbsp;&nbsp;[4;36;1mDashboard Load (87.7ms)[0m [0;1mSELECT \* FROM `dashboards` [0m Rendering template within layouts/application Rendering dashboards/index &nbsp;&nbsp;[4;35;1mDashboard Columns (28.2ms)[0m [0mSHOW FIELDS FROM `dashboards`[0m &nbsp;&nbsp;[4;36;1mUser Columns (3.9ms)[0m [0;1mSHOW FIELDS FROM `users`[0m Completed in 781ms (View: 631, DB: 121) | 200 OK [[http://localhost/\](http://localhost/%5C)]

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [December 6, 2010, 2:49pm UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/16 "2010-12-06T14:49:28Z")

</div>

> Did you delete the production.log? Did it get recreated when you started the application?

I'm not sure exactly what you mean, but this is what I tried. In textmate:

• I deleted production.log • Then restarted server locally

No file was recreated.

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [December 6, 2010, 3:43pm UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/17 "2010-12-06T15:43:59Z")

</div>

Actually after deleting it, it is recreated with this:

# Logfile created on Mon Dec 06 10:19:07 -0500 2010

But nothing else.

---

<div class="post-metadata">

**Author:** ![hassan](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/hassan/32/714_2.png) [@hassan](https://discuss.rubyonrails.org/u/hassan)\
**Post date:** [December 6, 2010, 4:23pm UTC](https://discuss.rubyonrails.org/t/production-log-is-always-empty/56053/18 "2010-12-06T16:23:13Z")

</div>

> Actually after deleting it, it is recreated with this:
> 
> # Logfile created on Mon Dec 06 10:19:07 -0500 2010
> 
> But nothing else.

OK, instead of my original suggestion using logger:

Open a console in production mode and

> > RAILS\_DEFAULT\_LOGGER.info("what the hey")

instead try a simple `puts "-- hey, I'm talking to you"` and see if that shows up (again, anywhere, not just in the production log).

Also, what's the console output of

RAILS\_DEFAULT\_LOGGER
