How to write into rails log from a job?

1.9k Views Asked by At

I am facing an issue concerning logs. I built a rails app using ActiveJob with Sidekiq.

I want to write an entry into rails logs from a background job.

Usually, when I want to write an entry, I do something like this (in a controller for instance):

Rails.logger.fatal "BIG ISSUE!!!"

So I wanted to do the same but this time, in a background job:

class MyJob < ApplicationJob
  queue_as :default

  def perform(*args)
    Rails.logger.fatal"FATAL TEST"
  end
end

However nothing is written in the rails logs. Can you explain me why? And how to make this work?

1

There are 1 best solutions below

0
On

Sidekiq logs will go to the /var/log/syslog to redirect check out this article https://github.com/mperham/sidekiq/wiki/Logging