簡體   English   中英

記錄器不工作Elixir

[英]Logger not working Elixir

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

** (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獲得了幫助

您需要在模塊定義中添加require Logger ,例如在defmodule AAA...

例如: https//github.com/22cans/exsyslog/blob/2b9ea2be7d7fcc17eab061425b6cd4fad8643996/examples/example1/lib/example1.ex

得到它了 ! 它之所以不起作用是因為Logger沒有在同一個模塊中找到。 因此,必須導入模塊和函數才能使用它們。

所以我用過

require Logger

這解決了這個問題。 該計划再次開始運作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM