禁用Elixir Ecto调试输出 [英] Disable Elixir Ecto Debug output
问题描述
无论在 iex>
中还是在运行mix项目时使用 mix run -e My.code
使用ecto,Ecto的调试机制将显示一堆如下所示的SQL
Whatever in iex>
or using mix run -e "My.code"
when I run the mix project using ecto, the Ecto's Debugging Mechanism display a bunch of SQLs like below
16:42:12.870 [debug] SELECT a0.`id` FROM `account` AS a0 WHERE (a0.`account_name` = ?) ["71000000313"] (39.6ms)`
...
当我不再需要调试输出时,如何关闭它,我找不到有关如何更改ecto日志级别内容的任何信息。
When I dont need the debug output anymore, How can I turn it off, I cannot find anything about how to change ecto log level stuff.
谢谢。
推荐答案
您的日志记录级别已在中配置config /#{env} .exs
文件。如果您查看 config / prod.exs
,则很可能已经将该级别设置为:info
:
Your logging level is configured in your config/#{env}.exs
files. If you look into config/prod.exs
it most likely already has that level set to :info
:
config :logger, level: :info
因此,如果使用 MIX_ENV = prod iex -S mix
运行应用程序,则不会获得调试输出。这意味着,当您使用 MIX_ENV = prod mix release
之类的版本进行构建时,生成的结果将不会产生此输出。或者,您可以通过更改相应的<$ c $来为所需的任何环境设置 level::info
或:warn
c> config /#{env} .exs 。
So if you run the app with MIX_ENV=prod iex -S mix
you won't get the debug output. This means that when you build a release with something like MIX_ENV=prod mix release
the resulting build won't be producing this output. Alternatively you may set level: :info
or :warn
for whatever environment you want by changing the appropriate config/#{env}.exs
.
这篇关于禁用Elixir Ecto调试输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!