lager的输出可以定制,这里是我的定制方案。
在lager/ebin/lager.app里面的env字段里添加:
{env,[... {log_root, "log"}, {handlers, [ {lager_console_backend, error}, {lager_file_backend, [{file, "error.log"}, {level, error},{formatter, lager_default_formatter}, {formatter_config, ["=ERROR REPORT==== ", date, " ", time, " ===\n", sev, "(", pid, ":", module, ":", line, ") ", message, "\n\n"]}, {size, 10485760}, {date, "$D0"}, {count, 5}]}, {lager_file_backend, [{file, "console.log"}, {level, info}]} ]}, ... ]}.
输出的结果是这样子的:
=ERROR REPORT==== 2016-03-17 15:47:22.915 === E(<0.85.0>:log_module:36) I:1