繁体   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