Logging

tsuru aggregates stdout and stderr from every application process making iteasier to troubleshoot problems. To use the log make sure that your applicationis sending the log to stdout and stderr.

Watch your logs

On its default installation tsuru will have all logs available using the tsuru
app-log
command.

It’s possible that viewing logs using tsuru was disabled by an administrator. Inthis case running tsuru app-log will show instructions on how logs can beread.

For more informations about configuring the destination of logs andenabling/disabling tsuru app-log see Managing Application Logs.

Basic usage

  1. $ tsuru app-log -a <appname>
  2. 2014-12-11 16:36:17 -0200 [tsuru][api]: ---> Removed route from unit 1d913e0910
  3. 2014-12-11 16:36:17 -0200 [tsuru][api]: ---- Removing 1 old unit ----
  4. 2014-12-11 16:36:22 -0200 [app][11f863b2c14b]: Starting gunicorn 18.0
  5. 2014-12-11 16:36:22 -0200 [app][11f863b2c14b]: Listening at: http://0.0.0.0:8100 (51)
  6. 2014-12-11 16:36:22 -0200 [app][11f863b2c14b]: Using worker: sync
  7. 2014-12-11 16:36:22 -0200 [app][11f863b2c14b]: Booting worker with pid: 60
  8. 2014-12-11 16:36:28 -0200 [tsuru][api]: ---> Removed old unit 1/1

By default is showed the last ten log lines. If you want see more lines,you can use the -l/—lines parameter:

  1. $ tsuru app-log -a <appname> --lines 100

Filtering

You can filter logs by unit and by source.

To filter by unit you should use -u/–unit parameter:

  1. $ tsuru app-log -a <appname> --unit 11f863b2c14b
  2. 2014-12-11 16:36:22 -0200 [app][11f863b2c14b]: Starting gunicorn 18.0
  3. 2014-12-11 16:36:22 -0200 [app][11f863b2c14b]: Listening at: http://0.0.0.0:8100 (51)
  4. 2014-12-11 16:36:22 -0200 [app][11f863b2c14b]: Using worker: sync

See also

To get the unit id you can use the tsuru app-info -a <appname> command.

The log can be sent by your process or by tsuru api. To filter by sourceyou should use -s/—source parameter:

  1. $ tsuru app-log -a <appname> --source app
  2. 2014-12-11 16:36:22 -0200 [app][11f863b2c14b]: Starting gunicorn 18.0
  3. 2014-12-11 16:36:22 -0200 [app][11f863b2c14b]: Listening at: http://0.0.0.0:8100 (51)
  4. 2014-12-11 16:36:22 -0200 [app][11f863b2c14b]: Using worker: sync
  5.  
  6. $ tsuru app-log -a <appname> --source tsuru
  7. 2014-12-11 16:36:17 -0200 [tsuru][api]: ---> Removed route from unit 1d913e0910
  8. 2014-12-11 16:36:17 -0200 [tsuru][api]: ---- Removing 1 old unit ----

Realtime logging

tsuru app-log has a -f/—follow option that causes the log to not stop andwait for the new log data. With this option you can see in real time thebehaviour of your application that is useful to debug problems:

  1. $ tsuru app-log -a <appname> --follow

You can close the session pressing Ctrl-C.

原文: https://docs.tsuru.io/1.6/using/logging.html