'Is it possible to write delayed_jobs.log to log in Openshift pod?

The application that me and my team working on use Ruby on Rails hosted in Openshift pod. We use delayed_job to handle background process, and for delayed_job logging, the application write the log into log/delayed_job.log file. However, if a new pod for the application is created, the pod will create a new file. Also, the company is using Kibana to save every log from Openshift pod.

What we tried so far is put this code in delayed_job_config.rb

Delayed::Worker.logger = Logger.new(STDERR)

To write the log for another process beside delayed job, in order to write the log in Openshift pod log, we use this following code, e.g:

Rails.logger.info "Result: #{ldap.get_operation_result.code}"

However, the delayed_job log is not still appear in Logs tab of the pod (in order for the log to appear in Kibana)

The goal is to write the log in Logs tab of the Openshift pod.

enter image description here

Any help is appreciated.

UPDATE :

We tried to put Delayed::Worker.logger = Rails.logger in delayed_job_config.rb but still did not work



Solution 1:[1]

In general everything written to STDOUT or STDERR from the main process of the container/pod is appearing in the log tab. I guess you problem will be that your background work is not executed in the main process and therefore not shown in the log tab.

As an example we had an application where the start script was executing the actual work in another process. Even though this new process logged to STDOUT it will not appear in the log tab as OpenShift only shows the logs of the main process which was in our case the process executing the script.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Markus Kofler