RACK 记录到哪里? [英] Where does RACK log to?

查看:28
本文介绍了RACK 记录到哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过 RACK 运行 sinatra 应用程序.

I am running a sinatra app through RACK.

活动记录到哪个文件?另外如何设置日志文件路径?

To which file does the activity get logged ? Also how can I set the log file path ?

推荐答案

视情况而定.许多开发人员将他们的应用日志文件定义为 app/servername.log 或只是加载 Rack 应用的当前路径.

It depends. Many developers define their app log file to app/servername.log or just to the current path where the Rack app is loaded.

是的,您可以更改它的路径.

Yes you can change it's path.

通常你会得到一个 config.ru 文件,内容如下:

Usually you get a config.ru file with something like:

    log = File.new("sinatra.log", "a+")
    $stdout.reopen(log)
    $stderr.reopen(log)

    # optionally to sync logs while the server is running
    $stderr.sync = true
    $stdout.sync = true

和/或

    configure do
      LOGGER = Logger.new("sinatra.log")
      enable :logging, :dump_errors
      set :raise_errors, true
    end

在这种情况下,日志文件位于 appdir/sinatra.log 下.但请记住,此代码可以位于您的 Rack 应用程序中的任何位置,因此请在您的应用程序目录中查找log".

in this case the log file is located under appdir/sinatra.log. But remember this code can be anywhere in your Rack app, so please seek for "log" in your application directory.

    $ cd projectname
    $ grep -ri 'log' *

玩得开心,在这里发布您的 config.ru 和/或 mainprojectfile.rb.

have fun and post here your config.ru and/or the mainprojectfile.rb.

这篇关于RACK 记录到哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆