When I run "ruby script/server" to start rails server, the current shell
will be blocked and all the output from rails will be written to the
current console. Does rails support a non-block mode and let the output
to be written to a specified log file?
Use the -d option with the `ruby script/server` program. Then WEBrick
server will run as a daemon.
> Hi, you should be able to configure the log_path by adding it to the
> initializer block in your environment.rb. For example,
> Rails::Initializer.run do |config|
> ...
> # Note: By default, the log_path is set to log/#{environment}.log
> config.log_path = <some_absolute_file_path>
> end
This log is rails log. What I want is application log. For example, in
my controller, I use puts to print message to the console, I will to log
this output.
Don't use puts, use Rails.logger.info (or whatever log level you
want). Or you can create and pass around your own logger object but
why bother ?