lager to logger

This commit is contained in:
anlicheng 2026-02-11 15:44:53 +08:00
parent de71af2dbf
commit eb015f1a67
3 changed files with 49 additions and 58 deletions

View File

@ -61,37 +61,29 @@
]}, ]},
%% 系统日志配置系统日志为lager, 支持日志按日期自动分割 %% 系统日志配置系统日志为lager, 支持日志按日期自动分割
{lager, [ {kernel, [
{colored, true}, %% 设置 Logger 的 primary log level
%% Whether to write a crash log, and where. Undefined means no crash logger. {logger_level, debug},
{crash_log, "trade_hub.crash.log"}, {logger, [
%% Maximum size in bytes of events in the crash log - defaults to 65536 {handler, default, logger_std_h,
{crash_log_msg_size, 65536}, #{
%% Maximum size of the crash log in bytes, before its rotated, set level => debug,
%% to 0 to disable rotation - default is 0 formatter => {logger_formatter, #{template => [time, " [", level, "] ", msg, "\n"]}}
{crash_log_size, 10485760}, }
%% What time to rotate the crash log - default is no time },
%% rotation. See the README for a description of this format.
{crash_log_date, "$D0"},
%% Number of rotated crash logs to keep, 0 means keep only the
%% current one - default is 0
{crash_log_count, 5},
%% Whether to redirect error_logger messages into lager - defaults to true
{error_logger_redirect, true},
%% How big the gen_event mailbox can get before it is switched into sync mode {handler, disk, logger_disk_log_h,
{async_threshold, 20}, #{
%% Switch back to async mode, when gen_event mailbox size decrease from `async_threshold' level => debug,
%% to async_threshold - async_threshold_window config => #{
{async_threshold_window, 5}, file => "log/debug.log",
max_no_files => 10,
max_no_bytes => 524288000
},
formatter => {logger_formatter, #{template => [time, " [", level, "] ", msg, "\n"]}}
}
}
{handlers, [
%% debug | info | warning | error, 日志级别
{lager_console_backend, debug},
{lager_file_backend, [{file, "debug.log"}, {level, debug}, {size, 314572800}]},
{lager_file_backend, [{file, "notice.log"}, {level, notice}, {size, 314572800}]},
{lager_file_backend, [{file, "error.log"}, {level, error}, {size, 314572800}]},
{lager_file_backend, [{file, "info.log"}, {level, info}, {size, 314572800}]}
]} ]}
]} ]}
]. ].

View File

@ -62,37 +62,29 @@
]}, ]},
%% 系统日志配置系统日志为lager, 支持日志按日期自动分割 %% 系统日志配置系统日志为lager, 支持日志按日期自动分割
{lager, [ {kernel, [
{colored, true}, %% 设置 Logger 的 primary log level
%% Whether to write a crash log, and where. Undefined means no crash logger. {logger_level, debug},
{crash_log, "trade_hub.crash.log"}, {logger, [
%% Maximum size in bytes of events in the crash log - defaults to 65536 {handler, default, logger_std_h,
{crash_log_msg_size, 65536}, #{
%% Maximum size of the crash log in bytes, before its rotated, set level => debug,
%% to 0 to disable rotation - default is 0 formatter => {logger_formatter, #{template => [time, " [", level, "] ", msg, "\n"]}}
{crash_log_size, 10485760}, }
%% What time to rotate the crash log - default is no time },
%% rotation. See the README for a description of this format.
{crash_log_date, "$D0"},
%% Number of rotated crash logs to keep, 0 means keep only the
%% current one - default is 0
{crash_log_count, 5},
%% Whether to redirect error_logger messages into lager - defaults to true
{error_logger_redirect, true},
%% How big the gen_event mailbox can get before it is switched into sync mode {handler, disk, logger_disk_log_h,
{async_threshold, 20}, #{
%% Switch back to async mode, when gen_event mailbox size decrease from `async_threshold' level => debug,
%% to async_threshold - async_threshold_window config => #{
{async_threshold_window, 5}, file => "log/debug.log",
max_no_files => 10,
max_no_bytes => 524288000
},
formatter => {logger_formatter, #{template => [time, " [", level, "] ", msg, "\n"]}}
}
}
{handlers, [
%% debug | info | warning | error, 日志级别
{lager_console_backend, debug},
{lager_file_backend, [{file, "debug.log"}, {level, debug}, {size, 314572800}]},
{lager_file_backend, [{file, "notice.log"}, {level, notice}, {size, 314572800}]},
{lager_file_backend, [{file, "error.log"}, {level, error}, {size, 314572800}]},
{lager_file_backend, [{file, "info.log"}, {level, info}, {size, 314572800}]}
]} ]}
]} ]}
]. ].

View File

@ -54,10 +54,15 @@
{git,"https://github.com/devinus/poolboy.git", {git,"https://github.com/devinus/poolboy.git",
{ref,"3bb48a893ff5598f7c73731ac17545206d259fac"}}, {ref,"3bb48a893ff5598f7c73731ac17545206d259fac"}},
0}, 0},
{<<"quicer">>,
{git,"https://github.com/emqx/quic.git",
{ref,"c2962fd732caa29d513de7c645ea307cf89aaa9c"}},
0},
{<<"ranch">>, {<<"ranch">>,
{git,"https://github.com/ninenines/ranch", {git,"https://github.com/ninenines/ranch",
{ref,"a692f44567034dacf5efcaa24a24183788594eb7"}}, {ref,"a692f44567034dacf5efcaa24a24183788594eb7"}},
1}, 1},
{<<"snabbkaffe">>,{pkg,<<"snabbkaffe">>,<<"1.0.10">>},1},
{<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.6">>},1}, {<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.6">>},1},
{<<"sync">>, {<<"sync">>,
{git,"https://github.com/rustyio/sync.git", {git,"https://github.com/rustyio/sync.git",
@ -77,6 +82,7 @@
{<<"idna">>, <<"1D038FB2E7668CE41FBF681D2C45902E52B3CB9E9C77B55334353B222C2EE50C">>}, {<<"idna">>, <<"1D038FB2E7668CE41FBF681D2C45902E52B3CB9E9C77B55334353B222C2EE50C">>},
{<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>}, {<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>},
{<<"mimerl">>, <<"67E2D3F571088D5CFD3E550C383094B47159F3EEE8FFA08E64106CDF5E981BE3">>}, {<<"mimerl">>, <<"67E2D3F571088D5CFD3E550C383094B47159F3EEE8FFA08E64106CDF5E981BE3">>},
{<<"snabbkaffe">>, <<"9BE2F54F61FC6862391B666B2B5B76C3FA53598E2989A17CEF1B48CF347A8A63">>},
{<<"ssl_verify_fun">>, <<"CF344F5692C82D2CD7554F5EC8FD961548D4FD09E7D22F5B62482E5AEAEBD4B0">>}, {<<"ssl_verify_fun">>, <<"CF344F5692C82D2CD7554F5EC8FD961548D4FD09E7D22F5B62482E5AEAEBD4B0">>},
{<<"unicode_util_compat">>, <<"8516502659002CEC19E244EBD90D312183064BE95025A319A6C7E89F4BCCD65B">>}]}, {<<"unicode_util_compat">>, <<"8516502659002CEC19E244EBD90D312183064BE95025A319A6C7E89F4BCCD65B">>}]},
{pkg_hash_ext,[ {pkg_hash_ext,[
@ -87,6 +93,7 @@
{<<"idna">>, <<"A02C8A1C4FD601215BB0B0324C8A6986749F807CE35F25449EC9E69758708122">>}, {<<"idna">>, <<"A02C8A1C4FD601215BB0B0324C8A6986749F807CE35F25449EC9E69758708122">>},
{<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>}, {<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>},
{<<"mimerl">>, <<"F278585650AA581986264638EBF698F8BB19DF297F66AD91B18910DFC6E19323">>}, {<<"mimerl">>, <<"F278585650AA581986264638EBF698F8BB19DF297F66AD91B18910DFC6E19323">>},
{<<"snabbkaffe">>, <<"70A98DF36AE756908D55B5770891D443D63C903833E3E87D544036E13D4FAC26">>},
{<<"ssl_verify_fun">>, <<"BDB0D2471F453C88FF3908E7686F86F9BE327D065CC1EC16FA4540197EA04680">>}, {<<"ssl_verify_fun">>, <<"BDB0D2471F453C88FF3908E7686F86F9BE327D065CC1EC16FA4540197EA04680">>},
{<<"unicode_util_compat">>, <<"D48D002E15F5CC105A696CF2F1BBB3FC72B4B770A184D8420C8DB20DA2674B38">>}]} {<<"unicode_util_compat">>, <<"D48D002E15F5CC105A696CF2F1BBB3FC72B4B770A184D8420C8DB20DA2674B38">>}]}
]. ].