From 367c081eaf28009db3462e6eabccc1ec9c730527 Mon Sep 17 00:00:00 2001 From: lsxredrain <34489690@qq.com> Date: Sun, 22 Aug 2021 01:44:54 +0800 Subject: [PATCH] change to json log --- apps/dgiot/include/logger.hrl | 2 +- apps/dgiot/src/utils/dgiot_datetime.erl | 1 + apps/dgiot/src/utils/dgiot_license.erl | 1 + etc/emqx.conf | 2 +- priv/emqx.schema | 2 +- 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/dgiot/include/logger.hrl b/apps/dgiot/include/logger.hrl index be9b57a3..1e5b243b 100644 --- a/apps/dgiot/include/logger.hrl +++ b/apps/dgiot/include/logger.hrl @@ -44,7 +44,7 @@ -define(LOG(Level, Format, Args), begin (logger:log(Level,#{},#{report_cb => fun(_) -> - {'$logger_header'() ++ "[~p:~p ~p] [~s:~p] " ++ (Format), ([?MODULE, ?FUNCTION_NAME, ?LINE, node(),self()] ++ Args)} end, + {'$logger_header'() ++ (Format), ( Args)} end, mfa => {?MODULE, ?FUNCTION_NAME, ?FUNCTION_ARITY}, line => ?LINE})) end). diff --git a/apps/dgiot/src/utils/dgiot_datetime.erl b/apps/dgiot/src/utils/dgiot_datetime.erl index 682d1c42..db5fba9c 100644 --- a/apps/dgiot/src/utils/dgiot_datetime.erl +++ b/apps/dgiot/src/utils/dgiot_datetime.erl @@ -18,6 +18,7 @@ -module(dgiot_datetime). -author("johnliu"). -include_lib("dgiot/include/logger.hrl"). +-logger_header("[dgiot]"). -export([ start_time/0, diff --git a/apps/dgiot/src/utils/dgiot_license.erl b/apps/dgiot/src/utils/dgiot_license.erl index 86d08f18..cd696871 100644 --- a/apps/dgiot/src/utils/dgiot_license.erl +++ b/apps/dgiot/src/utils/dgiot_license.erl @@ -17,6 +17,7 @@ -module(dgiot_license). -author("johnliu"). -include_lib("dgiot/include/logger.hrl"). +-logger_header("[dgiot]"). -export([init/1 , description/0 diff --git a/etc/emqx.conf b/etc/emqx.conf index 6f2fe55f..d2945ec6 100644 --- a/etc/emqx.conf +++ b/etc/emqx.conf @@ -448,7 +448,7 @@ log.file = emqx.log ## Log formatter ## Value: text | json -#log.formatter = text +log.formatter = json ## Log to single line ## Value: Boolean diff --git a/priv/emqx.schema b/priv/emqx.schema index 142a9acf..904c99ec 100644 --- a/priv/emqx.schema +++ b/priv/emqx.schema @@ -502,7 +502,7 @@ end}. %% @doc format logs as JSON objects {mapping, "log.formatter", "kernel.logger", [ - {default, text}, + {default, json}, {datatype, {enum, [text, json]}} ]}.