简体   繁体   English

将位于Heroku的Node.js应用日志发送到文件

[英]Send Node.js app logs located at Heroku to file

I have problem with sending Node.js app logs located at Heroku to file. 将位于Heroku的Node.js应用日志发送到文件时遇到问题。 I'm using well known logger . 我正在使用知名的记录器 When I clone code from Heroku to my local computer logfile is empty. 当我将代码从Heroku克隆到本地计算机时,日志文件为空。 No errors. 没有错误。 Application opened on local server sends logs to file with no problems. 在本地服务器上打开的应用程序将日志发送到文件没有问题。 Where is mistake? 错误在哪里?

Heroku's ephemeral filesystem makes logging to a file impractical. Heroku的临时文件系统使记录到文件变得不切实际。 Any changes you make to it, eg adding or modifying files, will be lost whenever your dyno restarts. 每当您的dyno重新启动时,您对其所做的任何更改(例如添加或修改文件)都将丢失。 This happens frequently (at least once per day). 经常发生 (每天至少一次)。

Even if this weren't the case, if you clone from Heroku the log files wouldn't be included since they're not committed to your repository. 即使不是这种情况,但是如果您从Heroku克隆,则不会包含日志文件,因为它们没有提交到您的存储库中。 (This is good—log files should never be tracked.) (这很好–永远不要跟踪日志文件。)

Your best bet for having persistent, long-term logs is to use a logging addon or set up a log drain . 拥有持久的长期日志的最佳选择是使用日志记录插件或设置日志消耗

Finally, note that cloning from Heroku is an anti-pattern : 最后,请注意, 从Heroku克隆是一种反模式

Heroku provides the git service primarily for deployment, and the ability to clone from it is offered as a convenience. Heroku主要为部署提供git服务,并提供了从中克隆功能的便利。 We strongly recommend you store your code in another git repository such as GitHub and treat that as canonical. 我们强烈建议您将代码存储在另一个git存储库(例如GitHub)中 ,并将其视为规范。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM