Where does RACK log to?

前端 未结 3 2030
日久生厌
日久生厌 2021-02-07 14:29

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 ?

3条回答
  •  长发绾君心
    2021-02-07 14:58

    The object_id are initially the same but it's better to assign to $stderr. That also leaves you open to return the stream to where it was originally with STDERR:

     $ irb
    >> $stderr.object_id == STDERR.object_id
    => true
    

    Same object, for now. Send it elsewhere,

    >> $stderr = File.open('/tmp/foo', 'w')
    => #
    >> $stderr.puts "Uh-oh, foo"
    => nil
    >> $stderr.flush    # if you want to verify its output
    => #
    >> $stderr.object_id == STDERR.object_id
    => false
    

    $stderr and STDERR refer to different objects. STDERR still streams to the terminal here,

    >> STDERR.puts "Uh-oh, original STDERR"
    Uh-oh, original STDERR
    => nil
    

    Restore $stderr,

    >> $stderr = STDERR
    => #
    >> $stderr.object_id == STDERR.object_id
    => true
    

    And we're back!

提交回复
热议问题