I have a heroku app deployed. In that app, whenever something happens, my program stores the logs in a file. But the logs are not showing in my github repository. How can I get the logs stored in the file and the file kepp getting updated?
CodePudding user response:
Heroku's ephemeral filesystem makes file-based logging impractical. Any changes you make to the filesystem will be lost the next time your dyno restarts. This happens frequently (at least once per day).
Logs should simply be printed to stdout
or stderr
. Heroku will capture them and include them in its log stream, which you can view by running heroku logs
or via the dashboard.
The log stream doesn't keep very many logs, or store them for very long, but you can use a logging add-on or implement a log drain if you wish:
Logplex is designed for collating and routing log messages, not for storage. It retains the most recent 1,500 lines of your consolidated logs, which expire after 1 week.
For more production-ready persistence of logs, add one of the Heroku platform’s available logging add-ons to your app. Most of these add-ons offer a free plan to get started.
Alternatively, implement your own log drains for full control over what happens to your logs.