加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

erlang – 在Elixir伞应用程序中,应该将logger后端应用程序添加

发布时间:2020-12-13 20:09:48 所属栏目:百科 来源:网络整理
导读:我有一个Elixir伞形应用程序.伞下的应用程序使用 Logger.我想为:logger应用程序添加后端( logger_logstash_backend).所以,我需要在混合文件中添加它作为deps函数的依赖项. 在伞形应用程序的最外层混合文件中,deps函数的文档说明: Dependencies listed here
我有一个Elixir伞形应用程序.伞下的应用程序使用 Logger.我想为:logger应用程序添加后端( logger_logstash_backend).所以,我需要在混合文件中添加它作为deps函数的依赖项.

在伞形应用程序的最外层混合文件中,deps函数的文档说明:

Dependencies listed here are available only for this project
and cannot be accessed from applications inside the apps folder

这意味着我必须将后端模块添加为伞下每个应用程序的依赖项.但是,这样做会导致几个问题:

>以后将单个应用程序移出单独的库变得更加困难.
>伞下的各个应用程序实际上并不依赖于自定义:记录器后端模块.默认情况下它们没问题:控制台后端.但我想只为prod环境增加一个后端.因此,更多的是跨应用程序问题,我不得不单独向每个应用程序添加依赖项.

你知道更好的策略吗?它是什么?

每个应用程序都应该有自己的依赖项和配置.

你提到的问题:

  1. It becomes harder to move out the individual applications as separate
    libraries later.

如果您在每个应用程序中都有配置,这实际上可以更轻松地将各个应用程序移出伞形应用程序.如Elixir guides中所述,您只需将应用程序移出apps /目录即可.

  1. The individual applications under the umbrella are not actually dependent on the custom :logger backend module. They’re okay with default :console backend. But I want to have an additional backend only for prod environment. Therefore,it’s more of a cross-applications concern where I’m forced to add the dependency to each application individually.

如果仅在生产环境中需要自定义记录器后端,则应用程序只能将此配置添加到config / prod.exs文件中,并仅在prod环境中使用此配置.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读