I am logging some errors by doing this in my Rails app:
logger.error "MY ERROR STRING"
How can I look in heroku logs to find that line?
I know how to do heroku logs --tail
and heroku logs -n 500
,but how can I find a specific string in the logs?
You can view logs with the Heroku CLI, the dashboard, your logging add-on, or in your log drain. You can't view logs for apps in Shield spaces with Private Space Logging enabled. Retrieve logs from your log drain instead.
If running heroku local does not help, run a remote shell: heroku run -a <your app name> /bin/bash , and there run npm start to see the logs and debug the issue on the Heroku server.
Just go to Papertrail > Dashboard > lower right corner > Filter logs. and papertrail will ignore all heroku/router logs.
Get Started with the Heroku CLI After you install the CLI, run the heroku login command. Enter any key to go to your web browser to complete login. The CLI then logs you in automatically. If you'd prefer to stay in the CLI to enter your credentials, run heroku login -i .
Using heroku logs -t | grep "term"
is great for filtering current log events. However, Heroku retains a max of 1500 lines of log output, so even if you do heroku logs -n 1500 -t
you won't see log events that occurred prior to that log window.
The better approach is to use a logging add-on like Papertrail that retains your logs for a greater period of time and makes your full log history searchable.
Of course, it also possible that the log event you think is triggering in your code isn't.
Try putting | grep "search term"
after your heroku logs -n 500
statement
so something like: heroku logs -n 500 | grep "MY ERROR STRING"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With