2015-11-26 86 views
3

我正在嘗試將Logger.debug/1用於我的web項目。即使我添加了/ myApp/config中的配置文件(config.exs),我也無法通過此錯誤消息。Logger not working Elixir

** (CompileError) web/controllers/api/app_controller.ex:36: you must require Logger before invoking the macro Logger.debug/1 

我在最後添加了這個特定的配置。

config :logger, 
    backends: [:console], 
    compile_time_purge_level: :info 

我帶的幫助,使這除了從http://elixir-lang.org/docs/master/logger/Logger.html

回答

1

明白了!之所以不工作,是因爲在同一模塊中找不到Logger。所以必須導入模塊和功能才能使用它們。

所以我用

require Logger 

,這解決了這個問題。該計劃再次開始工作。

+0

我認爲Zepplock的答案涵蓋了這個很好。 –

+0

我同意@onoriocatenacci – srajappa