diff --git a/rebar.config b/rebar.config index 1ca235d63..29a6b0e11 100644 --- a/rebar.config +++ b/rebar.config @@ -19,7 +19,7 @@ %%%---------------------------------------------------------------------- {deps, [{lager, ".*", {git, "https://github.com/erlang-lager/lager", - {tag, {if_version_above, "17", "3.4.2", "3.2.1"}}}}, + {tag, {if_version_above, "17", "3.6.5", "3.2.1"}}}}, {p1_utils, ".*", {git, "https://github.com/processone/p1_utils", "6ff85e8"}}, {cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.14"}}}, {fast_tls, ".*", {git, "https://github.com/processone/fast_tls", "f36ea5b74526c2c1c9c38f8d473168d95804f59d"}}, diff --git a/src/ejabberd_logger.erl b/src/ejabberd_logger.erl index 2b3eab0eb..aac0baf59 100644 --- a/src/ejabberd_logger.erl +++ b/src/ejabberd_logger.erl @@ -143,10 +143,14 @@ do_start(Level) -> LogRotateSize = get_integer_env(log_rotate_size, 10*1024*1024), LogRotateCount = get_integer_env(log_rotate_count, 1), LogRateLimit = get_integer_env(log_rate_limit, 100), + ConsoleLevel = case get_lager_version() >= "3.6.0" of + true -> [{level, Level}]; + false -> Level + end, application:set_env(lager, error_logger_hwm, LogRateLimit), application:set_env( lager, handlers, - [{lager_console_backend, Level}, + [{lager_console_backend, ConsoleLevel}, {lager_file_backend, [{file, ConsoleLog}, {level, Level}, {date, LogRotateDate}, {count, LogRotateCount}, {size, LogRotateSize}]}, {lager_file_backend, [{file, ErrorLog}, {level, error}, {date, LogRotateDate}, @@ -252,3 +256,10 @@ get_lager_handlers() -> Result -> Result end. + +get_lager_version() -> + Apps = application:loaded_applications(), + case lists:keyfind(lager, 1, Apps) of + {_, _, Vsn} -> Vsn; + false -> "0.0.0" + end.