

By viewing a live stream of logs from your app, you can gain insight into the behavior of your live application and debug current problems. Similar to tail -f, real-time tail displays recent logs and leaves the session open for real-time logs to stream in.

You can specify the number of log lines to retrieve (up to a maximum of 1,500 lines) by using the -num (or -n) option. The logs command retrieves 100 log lines by default. See Heroku’s Log Format and Message Ordering for more info. In this example, the output includes log lines from one of the app’s web dynos, the Heroku HTTP router, and one of the app’s workers. To fetch your app’s most recent logs, use the heroku logs command: $ heroku logs

If you see an error in your logs, refer to Heroku Error Codes or the troubleshooting articles for more info. You can view logs with the Heroku CLI, the dashboard, your logging add-on, or in your log drain. See Writing Best Practices For Application Logs for more info. For example, when using the Ruby on Rails TaggedLogger by ActiveSupport, add the following into your app’s configuration to get stdout logging: config.logger = Logger.new(STDOUT) Some frameworks send log output somewhere other than stdout by default and require extra configuration.
PLACE TO WRITE APP CODE
For example, in Ruby, add the following code to your file: $stdout.sync = true To take advantage of real-time logging, disable any log buffering your application performs. The same holds true for all other languages supported by Heroku. In Ruby, you could use something like: puts "Hello, logs!" You can log from anywhere in your application code with a simple output statement. Your logs capture anything your app writes to standard out ( stdout) or standard error ( stderr).
PLACE TO WRITE APP FULL
Most of these add-ons offer a free plan to get started.Īlternatively, implement your own log drains for full control over what happens to your logs. It retains the most recent 1,500 lines of your consolidated logs, which expire after 1 week.įor more production-ready persistence of logs, add one of the Heroku platform’s available logging add-ons to your app. Logplex is designed for collating and routing log messages, not for storage. Logs for both successful and unsuccessful builds are available from your app’s Activity tab in the Heroku Dashboard:Ĭlick View build log for any build event in the Activity Feed to see its logs: The logs generated while building and deploying your app are separate from the app’s runtime logs. See the add-on’s Dev Center article for details.
