I would love to see a timestamp in each line of unicorn stderr and stdout logs. Has this been considered? Thanks. Best, alex sharp
On Fri, Jul 1, 2011 at 10:07 AM, Alex Sharp <ajsharp at gmail.com> wrote:> I would love to see a timestamp in each line of unicorn stderr and > stdout logs. Has this been considered? Thanks.+1 -Greg
Alex Sharp <ajsharp at gmail.com> wrote:> I would love to see a timestamp in each line of unicorn stderr and > stdout logs. Has this been considered? Thanks.Unicorn itself never writes directly to stdout[1]. Once daemonized, it never writes to stderr directly, either. If it does either of these, it''s a bug in Unicorn and needs to be reported and fixed. All writing through stderr happens through a Logger object which does timestamping/formatting, but Rails may screw up the formatting:>From the {FAQ}[http://unicorn.bogomips.org/FAQ.html]:| === Why are log messages from Unicorn are unformatted when using Rails? | | Current versions of Rails unfortunately overrides the default Logger | formatter. | | You can undo this behavior with the default logger in your Unicorn | config file: | | Configurator::DEFAULTS[:logger].formatter = Logger::Formatter.new | | Of course you can specify an entirely different logger as well | with the "logger" directive described by Unicorn::Configurator. It would be helpful for somebody who uses Rails to fix this behavior in Rails. [1] - stdout is reserved for the application; I configure {clogger}[http://clogger.rubyforge.org/] to log to stdout if I''m using clogger. -- Eric Wong
On Fri, Jul 1, 2011 at 1:54 PM, Eric Wong <normalperson at yhbt.net> wrote:> Alex Sharp <ajsharp at gmail.com> wrote: >> I would love to see a timestamp in each line of unicorn stderr and >> stdout logs. Has this been considered? Thanks. > > Unicorn itself never writes directly to stdout[1]. ?Once daemonized, it > never writes to stderr directly, either. ?If it does either of these, > it''s a bug in Unicorn and needs to be reported and fixed. > > All writing through stderr happens through a Logger object which does > timestamping/formatting, but Rails may screw up the formatting:I use these options in my config/unicorn.rb: stderr_path "/data/myapp/shared/log/unicorn.stderr.log" stdout_path "/data/myapp/shared/log/unicorn.stdout.log" So maybe that''s what Alex is referring to as well. I do see un-timestamped output in both files (some from my OobGC-fork middleware). The logger configuration you mentioned is intended to be used with those? -Greg
On Fri, Jul 1, 2011 at 2:23 PM, <ghazel at gmail.com> wrote:> I use these options in my config/unicorn.rb: > stderr_path "/data/myapp/shared/log/unicorn.stderr.log" > stdout_path "/data/myapp/shared/log/unicorn.stdout.log" > > So maybe that''s what Alex is referring to as well. I do see > un-timestamped output in both files (some from my OobGC-fork > middleware). The logger configuration you mentioned is intended to be > used with those? >Yes, these are the logs I was referring to, not application level logging. These logs output information when new workers are forked, when the server starts, etc. My apologies, I should have been more specific. Best, alex sharp github.com/ajsharp twitter.com/ajsharp alexjsharp.com 615.243.1472
ghazel at gmail.com wrote:> I use these options in my config/unicorn.rb: > stderr_path "/data/myapp/shared/log/unicorn.stderr.log" > stdout_path "/data/myapp/shared/log/unicorn.stdout.log" > > So maybe that''s what Alex is referring to as well. I do see > un-timestamped output in both files (some from my OobGC-fork > middleware). The logger configuration you mentioned is intended to be > used with those?Yes. You should be able to access the same Logger instance via env["rack.logger"] in your app/middleware (IIRC env["rack.logger"] is required for Rack 1.2). -- Eric Wong