---
title: "Rails 7.1 adds support for logging background job enqueue callers"
description:
  "Rails 7.1 adds support for logging background job enqueue callers."
canonical_url: "https://www.bigbinary.com/blog/rails-7-1-adds-support-for-logging-background-job-enqueue-callers"
markdown_url: "https://www.bigbinary.com/blog/rails-7-1-adds-support-for-logging-background-job-enqueue-callers.md"
---

# Rails 7.1 adds support for logging background job enqueue callers

Rails 7.1 adds support for logging background job enqueue callers.

- Author: Vishnu M
- Published: April 18, 2023
- Categories: Rails, Rails 7

Rails 7.1 has introduced a new option in Active Job that allows us to add
support for logging background job enqueue callers. It provides information
about the location from where a job was enqueued, which can be immensely helpful
during debugging. The following is an example of what the log output looks like:

```ruby
[ActiveJob] Enqueued NotifySubscribersJob (Job ID: 5945980f-303e-4c3f-af5b-e22be170f7c5) to Sidekiq(default)
[ActiveJob] ↳ app/models/post.rb:14 in `notify_subscribers`
```

By examining the logs above, we can determine that the `NotifySubscribersJob`
was enqueued from the `notify_subscribers` method in the `Post` model, providing
us with a clear picture of the job's origin.

To enable this functionality, we need to set the following configuration in
`config/environments/development.rb`.

```rb
config.active_job.verbose_enqueue_logs = true
```

However, Rails 7.1 ships with this configuration set by default.

It's important to note that using verbose enqueue logs in a production
environment is not recommended, as it uses the
[Kernel#caller](https://apidock.com/ruby/Kernel/caller) method to retrieve the
execution stack, which can be slow.

Please check out this [pull request](https://github.com/rails/rails/pull/47839)
for more details.

## Links

- [Human page](https://www.bigbinary.com/blog/rails-7-1-adds-support-for-logging-background-job-enqueue-callers)
