This will include logs generated from
Messages about actions taken by the Heroku platform infrastructure on behalf of your app, such as:
Messages about administrative actions taken by you and other developers working on your app, such as:
--source heroku --ps api)
[~/rack/rack-rock-paper-scissors(master)]$ heroku logs --source heroku --ps api 2013-10-23T21:33:41.105090+00:00 heroku[api]: Deploy 5ec1351 by firstname.lastname@example.org 2013-10-23T21:33:41.154690+00:00 heroku[api]: Release v7 created by email@example.com
Logplex is designed for collating and routing log messages, not for storage. It keeps the last 1,500 lines of consolidated logs.
Heroku recommends using a separate service for long-term log storage; see Syslog drains for more information.
Anything written to standard out (stdout) or standard error (stderr) is captured into your logs. This means that you can log from anywhere in your application code with a simple output statement:
puts "Hello, logs!"To take advantage of the realtime logging, you may need to disable any log buffering your application may be carrying out. For example, in Ruby add this to your config.ru:
$stdout.sync = trueSome frameworks send log output somewhere other than stdout by default.
$ heroku logs 2010-09-16T15:13:46.677020+00:00 app[web.1]: Processing PostController#list (for 126.96.36.199 at 2010-09-16 15:13:46) [GET] 2010-09-16T15:13:46.677023+00:00 app[web.1]: Rendering template within layouts/application 2010-09-16T15:13:46.677902+00:00 app[web.1]: Rendering post/list 2010-09-16T15:13:46.678990+00:00 app[web.1]: Rendered includes/_header (0.1ms) 2010-09-16T15:13:46.698234+00:00 app[web.1]: Completed in 74ms (View: 31, DB: 40) | 200 OK [http://myapp.heroku.com/] 2010-09-16T15:13:46.723498+00:00 heroku[router]: at=info method=GET path=/posts host=myapp.herokuapp.com fwd="188.8.131.52" dyno=web.1 connect=1ms service=18ms status=200 bytes=975 2010-09-16T15:13:47.893472+00:00 app[worker.1]: 2 jobs processed at 16.6761 j/s, 0 failed ...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.
The logs command retrieves 100 log lines by default.
When retrieving logs, you may notice that the logs are not always in order, especially when multiple components are involved.
This is likely an artifact of distributed computing.
Logs originate from many sources (router nodes, dynos, etc) and are assembled into a single log stream by logplex.
It is up to the logplex user to sort the logs and provide the ordering required by their application, if any
You can fetch up to 1500 lines using the -num (or -n) option:
$ heroku logs -n 200Heroku only stores the last 1500 lines of log history. If you’d like to persist more than 1500 lines, use a logging add-on or create your own syslog drain52.1.
Each line is formatted as follows:
worker #3appears as
worker.3, and the Heroku HTTP router appears as router.
tail -f, realtime tail displays recent logs and leaves the session open for realtime logs to stream in.
$ heroku logs --tailWhen you are done, press Ctrl-C to close the session.
If you only want to fetch logs with a certain source, a certain
dyno, or both, you can use the
-p) filtering arguments:
$ heroku logs --ps router 2012-02-07T09:43:06.123456+00:00 heroku[router]: at=info method=GET path=/stylesheets/dev-center/library.css host=devcenter.heroku.com fwd="184.108.40.206" dyno=web.5 connect=1ms service=18ms status=200 bytes=13 2012-02-07T09:43:06.123456+00:00 heroku[router]: at=info method=GET path=/articles/bundler host=devcenter.heroku.com fwd="220.127.116.11" dyno=web.6 connect=1ms service=18ms status=200 bytes=20375
$ heroku logs --source app 2012-02-07T09:45:47.123456+00:00 app[web.1]: Rendered shared/_search.html.erb (1.0ms) 2012-02-07T09:45:47.123456+00:00 app[web.1]: Completed 200 OK in 83ms (Views: 48.7ms | ActiveRecord: 32.2ms) 2012-02-07T09:45:47.123456+00:00 app[worker.1]: [Worker(host:465cf64e-61c8-46d3-b480-362bfd4ecff9 pid:1)] 1 jobs processed at 23.0330 j/s, 0 failed ... 2012-02-07T09:46:01.123456+00:00 app[web.6]: Started GET "/articles/buildpacks" for 18.104.22.168 at 2012-02-07 09:46:01 +0000
$ heroku logs --source app --ps worker 2012-02-07T09:47:59.123456+00:00 app[worker.1]: [Worker(host:260cf64e-61c8-46d3-b480-362bfd4ecff9 pid:1)] Article#record_view_without_delay completed after 0.0221 2012-02-07T09:47:59.123456+00:00 app[worker.1]: [Worker(host:260cf64e-61c8-46d3-b480-362bfd4ecff9 pid:1)] 5 jobs processed at 31.6842 j/s, 0 failed ...
When filtering by dyno, either the base name,
--ps web, or the full
--ps web.1, may be used.
You can also combine the filtering switches with
--tail to get a
realtime stream of filtered output.
$ heroku logs --source app --tail