简体   繁体   English

如何将(机架)瘦服务器输出重定向到控制台?

[英]How to redirect (Rack) Thin server output to console?

Thin server has -l option to redirect output to log file (default: log/thin.log). 瘦服务器具有-l选项以将输出重定向到日志文件(默认值:log / thin.log)。 Is there a way like in webrick server the output is always to console (and log/development.log) too ? 有没有像webrick服务器那样的输出始终是控制台(和log / development.log)?

My installed version of Thin automatically outputs to the console. 我安装的Thin版本自动输出到控制台。 If yours doesn't, you could try updating your installed version. 如果您没有,则可以尝试更新已安装的版本。

You could also try thin -l - , which tells Thin to redirect output to STDOUT. 你也可以尝试thin -l - ,它告诉Thin将输出重定向到STDOUT。

Hope this helps! 希望这可以帮助!

If you're using rails, add this to your gemfile: 如果您正在使用rails,请将其添加到您的gemfile:

gem 'thin', :group => 'development'

And then from the console, use: 然后从控制台,使用:

rails s

This will send logs to standard out and to log/development.log 这会将日志发送到标准输出和log / development.log

Don't use "thin start", as some of the docs say. 一些文档说,不要使用“瘦启动”。

I use thin start -d to start thin as a background daemon with default logging and send the output of the file back to console with 我使用thin start -d作为具有默认日志记录的后台守护进程启动瘦,并将文件的输出发送回控制台

tail -f log/thin.log tail -f log / thin.log

This way the server doesn't stop if terminal closes, but I can see output from puts statements. 这样终端关闭时服务器不会停止,但我可以看到puts语句的输出。 If you want more detailed logging from thin that's a bit different. 如果你想从瘦的更详细的日志记录有点不同。

To stop the service/daemon use thin stop 要停止服务/守护程序,请使用thin stop

The solution is to add a small code snippet in your config.ru file, and thin output all app logs to the console, without having to tail the log file and it keeps the log coloring intact 解决方案是在config.ru文件中添加一个小代码片段,并将所有应用程序日志精简输出到控制台,而不必tail日志文件并保持日志着色不变

Details here: Thin server: Thin server: ouput rails application logs to console, as 'rails s' does 详细信息:瘦服务器: 瘦服务器:将应用程序日志输出到控制台,如'rails s'所示

我会自动输出到控制台,但如果我使用Procfile,它不会。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM