使用酿酒厂管理日志文件

Managing Log files with distillery

背景

使用蒸馏器启动 OTP 应用程序,我注意到所有日志都转到 ./var/log/ 文件夹到 2 个不同的文件:

问题

我这里有问题:

  1. 我不知道 run_erl.log 应该记录什么
  2. 我想将默认日志路径从 ./var/log/erlang.log.1 更改为 ./log/myapp.log

研究

我已经检查了这个讨论的一些提示,但根据它我必须更改 :logger 额外应用程序的配置。

Log files in Distillery releases

通过此搜索,我找到了以下使用 :logger_file_backend

的代码片段

https://snippets.aktagon.com/snippets/773-logging-to-a-file-with-elixir

不过我觉得我是在追逐野鹅。我不认为我的问题的解决方案在于添加更多依赖项,而是更改 :logger 应用程序的一些配置。

我只是不知道在哪里,也不知道如何。

我该怎么做?

您是否正在使用 bin/your_app start 来启动您的应用程序?在那种情况下,也许 RUNNER_LOG_DIR 是您正在寻找的用于自定义日志输出目录的变量。

我做了一个小调查,注意到与您的问题类似的问题“how to configure the path of the run_erl (for erlang.log.X, run_erl.log files)”。 RUNNER_LOG_DIR 在讨论中被提及。

distillery,依次列出 RUNNER_LOG_DIR as a configurable environment variable. It is then used when starting your application here.


I don’t know what run_erl.log is supposed to log.

根据官方 Erlang documentationrun_erl.log 用于记录来自 run_erl 程序本身的进度和警告。 run_erl 是启动应用程序的程序。

I would like to change the default log path from ./var/log/erlang.log.1 to ./log/myapp.log.

根据我的发现,应该可以更改日志文件的位置,但我还没有看到是否也可以更改文件的名称 (erlang.log.1 -> myapp.log),如果是的话还有你在问什么。如果您真的需要更改文件名,我会研究符号链接 myapp.logerlang.log.1.