Logging to STDOUT when integrated with ActiveJob

3,104 views
Skip to first unread message

Ryan Williams

unread,
Feb 14, 2015, 5:42:41 PM2/14/15
to sid...@googlegroups.com
I've started a new project with Sidekiq behind ActiveJob.

When I fire up Sidekiq locally using bundle exec sidekiq, I understand that the deafult logging behavior is to log to STDOUT, and sure enough, the Sidekiq logs start to show up

2015-02-14T22:20:24.404Z 28652 TID-ouxhmc8vs INFO: Running in ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
2015-02-14T22:20:24.404Z 28652 TID-ouxhmc8vs INFO: See LICENSE and the LGPL-3.0 for licensing details.
2015-02-14T22:20:24.404Z 28652 TID-ouxhmc8vs INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org/pro
2015-02-14T22:20:24.404Z 28652 TID-ouxhmc8vs INFO: Starting processing, hit Ctrl-C to stop
2015-02-14T22:20:24.450Z 28652 TID-ouxi4a268 INFO: Booting Sidekiq 3.3.2 with redis options {}
2015-02-14T22:20:24.450Z 28652 TID-ouxijme6o INFO: Booting Sidekiq 3.3.2 with redis options {}
2015-02-14T22:20:31.883Z 28652 TID-ouxhpmwm0 ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper JID-d39b0f7b48359dce3cda5294 INFO: start
2015-02-14T22:20:32.388Z 28652 TID-ouxhpmwm0 ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper JID-d39b0f7b48359dce3cda5294 INFO: done: 0.505 sec

But, for any direct logger calls, as the wiki page on logging[1] indicates, there is no output. However, the log statements show up in development.log. Similarly, the Sidekiq logs that show up on the terminal, do not appear in the development.log file.

class SomeJob < ActiveJob::Base
  queue_as
:default

 
def perform(*args)
    logger
.info "SomeJob starting"
 
end
end


I know it's a small thing to sync up the logs when developing locally, but does help streamline debugging, but is there a config to do so? To get logger.level calls inside an ActiveJob wrapped Sidekiq job logging to the terminal?



[1] https://github.com/mperham/sidekiq/wiki/Logging



Mike Perham

unread,
Feb 14, 2015, 11:48:36 PM2/14/15
to sid...@googlegroups.com
The "logger" that you are using in your ActiveJob class is *not* the same logger as the one Sidekiq exposes via Sidekiq::Worker#logger.  Sidekiq does not touch ActiveJob's logger so the two can easily be out of sync.



--
You received this message because you are subscribed to the Google Groups "Sidekiq" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sidekiq+u...@googlegroups.com.
To post to this group, send email to sid...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sidekiq/f95e2d3e-d120-40de-96c2-81d82c931c02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Mike Perham – Contributed Systems
Smart, effective open source infrastructure for your apps.

Gary Malouf

unread,
Mar 2, 2015, 7:30:28 PM3/2/15
to sid...@googlegroups.com
We recently updated from sidekiq 2.x to the latest sidekiq 3 release and are noticing behavior similar to what Ryan described.  The difference for us is that we are running sidekiq from bundle exec within runit, but the logs are not going to log file configured to capture sysout.  This used to work for sidekiq 2.x, was there a behavior change that would cause this?
Reply all
Reply to author
Forward
0 new messages