I have the program heroku_test.ts
console.log('test')
I can run it with the following command:
heroku run ts-node heroku_test.ts
In the same console window I see it output 'test'
But when I look at heroku logs, there is no 'test' there, it just says "Starting process with command ts-node heroku_test.ts"
Why heroku logs do not contain console.log output?
EDIT: the question is different from how to show all console.log from node.js in heroku? because I can see all the logs except any console.log output.
First install winston :
https://github.com/winstonjs/winston
as follows :
npm install winston --save
Then change your heroku_test.js to the following :
const winston = require('winston')
winston.log('info', '-------Hello log files!------------', {
someKey: 'some-value'
})
Then run
heroku run node heroku_test.js
Then check the logs :
heroku logs --tail
and you should see the above in the heroku logs
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