Can I get Rails debugging output in Pow similar to WEBrick? - ruby-on-rails

When I use rails/server (WEBrick) I get constant debug info (queries, etc) from my rails app as console output. Is there a way to get this debug output with Pow?
Thanks

You can check the HTTP requests that Pow receives by running tail -f on the log file of your choice in the ~/Library/Logs/Pow directory. Check out the Pow manual section on Viewing Log Files
If you're looking for Rails specific logs, they'll be located in the log/ directory of your application. For instance, if you want to watch the development log for your application switch to the root director of the application and run:
tail -f log/development.log
There's also less which will give you a few more options, but isn't quite as simple to use.
less -R log/development.log
and then press ctrl-f to follow new output to the file. Pressing h will give you a more detailed help menu.

You can also use a helper gem like powder. I order to show application log just type powder applog

Do you see a log/development.log path in your application? You can typically use that to see what is taking place within Rails. There are also logs for testing and production as well and they might be present for your project depending on the mode that the application is running in.
To access these logs you should use the Terminal and cd to your application, you can then use a utility such as tail to see the logs. A variation of the tail command would also scroll the output when there is new content like the Rails logger normally does.

Use the pry-remote gem.
References:
https://github.com/Mon-Ouie/pry-remote
https://coderwall.com/p/sreazq

Related

Rails logger logging to console

I am using Rails logger to log information in my Rails 4 application.
I do not set config.logger=Logger.new(STDOUT) in my configuration and just keep the default option for logger.However, besides the log file under /log folder, the information is still printed to the console when the statement Rails.logger.info is used.
Why does this happen as I only want the log info to be inside the log file, not printed to console? Thanks
Thats how rails s behaves. It puts the logs in log/development.log as well as show at the command line. As thats more convenient for most cases.
Anyways if you do not want it you can run your server something like this:
rails s 1> /dev/null
This would redirect all that text to /dev/null
If you only wants to print the log in log/development.log and not in the console, then use below to start your rails server.
rails s > log/development.log

Rails logs in staging are only writing to my log files. How do I get them to log to STDout or papertrail?

I currently have this issue that when there's an error, the logs in my terminal aren't informative. The logs are only writing to the log files but my terminal output doesn't show anything. This was super confusing. How do I change this?
What is the Rails default behavior anyway when it comes to logging?
In Rails, by default, each log is created under Rails.root/log/ and the log file is named after the environment in which the application is running.
But if you want to change you can specify something like below in config/application.rb which would throw out logs on STDOUT.
config.logger = Logger.new(STDOUT)
See the Rails guides for more info.
What I usually found easy was to tail the log on console like $ tail -f log/development.log and force/see the output of log file on console.

How can i track the issue in production RAILS

have on pdf creating function, but that PDF Generation different response, in local development working fine but the server shows 500 error. how can i track the issue in production ?
You can track issues in production in various way. There are several answers available. But better I should share very common practice regarding a rails application. If you are using apache/nginx as your http server. You can tail there log and make the operation on browser on the same time so you can get realtime log from the http server.
Next, based on your configuration (as per convention over configuration) there should be production.log in your app log directory. You can run the following command in your terminal/command line tools and check the log on real time:
tail -f log/production.log
I assumed in your case production.log is the log file currently logging everything by your production application server (passenger/unicorn/puma/etc..)
For assets and client end issues, try using your browser's console to inspect the issues.
I hope my answer will give you some idea!

Could I run a Rails Server and type commands to my Rails Project through terminal at the same time?

I'm running my rails server through the terminal by typing rails server. After this, it seems the terminal is unavailable for further commands, but I would like to run some tests by typing rake test without having to CTRL + C out of my server, then rake test, and finally turning my server back on with rails server. Is there common solution for this?
I would also recommend using several tabs or even a terminal multiplexer such as tmux. However you could very well send the server process to the background with
rails s &
This will most likely clutter up your terminal with lots of log output unless you suppress the output as described here. You can foreground the process by typing
fg
and even look at the logs in a different terminal by typing something along the lines of
tail -f log/development.log
Depending on your terminal you can use File->new tab, or maj+ctrl+t to pen a new tab.
Personally i have one tab for the server, one for the tests using guard, one for the console and one to have an actual shell.

Ruby on Rails: How to start the WEBrick server automatically on Windows in background?

In order to run the my Rails application on Windows XP I open a command line, cd to application's directory, and then run rails server.
I would like to automate this, such that every time I turn on my computer, all I'll have to do is to type localhost:3000 in a browser.
How could I do this ?
The simpler way is to create a batch file with the instruction what you give in the command prompt like
d:
cd projects\myapp
ruby script\server
and then drop a copy of the file to Windows Start -> All Programs -> start up folder.
You have few possibilities to do that.
using the registry you can use HKLM\Software\Microsoft\Windows\CurrentVersion\Run or the better approach would be to create a service, you can see this KB with some instruction how to make a service of whatever executable you want.
have you thought about , AUTOEXEC.BAT or creating some batch files. you create right cmd commands that are run at start up. http://www.aumha.org/a/batches.php
The best approach is turn your application into a service. There is a solution for Mongrel (a web server similar to webrick) called mongrel_service, but is not compatible with Rails 3 (due several changes of Rails internals)
However, you can repurpose mongrel_service codebase to work with thin, another webserver that works with Rails 3.
Please look here where is the only reference to mongrel_service script. changing it to thin start could work.
Perhaps is not the answer you're looking for (as there is some work to be done) but is something :)
start rubyw script/rails server webrick
start -> start in another console
rubyw -> run ruby detached from console

Resources