Skip to content

Instantly share code, notes, and snippets.

@raine
Last active August 3, 2018 19:14
Show Gist options
  • Save raine/f452cf1588bc7b78d04a to your computer and use it in GitHub Desktop.
Save raine/f452cf1588bc7b78d04a to your computer and use it in GitHub Desktop.
Read heroku log output with bunyan

Read heroku logs output w/ bunyan

The stuff before the JSON in heroku logs output has to be cut off for bunyan to work.

$ heroku logs | sed -l 's/.*app\[web\..*\]\: //' | bunyan

Flag -l makes the output buffered by line.

Alias

alias bunyan-heroku="sed -l 's/.*app\[web\..*\]\: //' | bunyan" 
$ heroku logs --tail | bunyan-heroku -o short

Previously used cut and awk, but found a better solution, for which a credit goes to @kennbrodhagen.

Excluding heroku[router]

One might not want to see the non-bunyan log output that comes from heroku[router].

In that case, pipe through grep:

alias buh="grep --line-buffered --color=none 'app\[web.\d\+\]' | sed -l 's/.*app\[web\..*\]\: //' | bunyan" 
@AdrieanKhisbe
Copy link

@f03lipe: the same for me. Looks like a sed vs gnu sed issue.

@the1mills
Copy link

thanks this looks useful

@GonzaloGM
Copy link

Thank you very much! :) On Windows this was what I used to get it working:

heroku logs --tail --remote heroku | sed -u 's/.*app\[web\..*\]\: //' | node_modules/.bin/bunyan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment