Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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" 
@felipap

This comment has been minimized.

Copy link

@felipap felipap commented Jun 6, 2015

Tried sed -u and it worked for me. :)

@AdrieanKhisbe

This comment has been minimized.

Copy link

@AdrieanKhisbe AdrieanKhisbe commented Jul 13, 2015

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

@the1mills

This comment has been minimized.

Copy link

@the1mills the1mills commented Oct 26, 2015

thanks this looks useful

@GonzaloGM

This comment has been minimized.

Copy link

@GonzaloGM GonzaloGM commented Jun 14, 2017

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