fix logger

This commit is contained in:
anlicheng 2026-01-15 16:12:15 +08:00
parent 2394db892c
commit 97019a87de
2 changed files with 24 additions and 29 deletions

View File

@ -47,6 +47,7 @@ handle_request("GET", "/test/get_network", #{<<"id">> := Id0}, _) ->
<<"name">> => <<"test1">>, <<"name">> => <<"test1">>,
<<"ipaddr">> => <<"10.211.179.0/24">>, <<"ipaddr">> => <<"10.211.179.0/24">>,
<<"owner_id">> => 1234, <<"owner_id">> => 1234,
<<"domain">> => <<"punchnet8.net">>,
<<"disabled_clients">> => [] <<"disabled_clients">> => []
}, },
9 => #{ 9 => #{
@ -54,6 +55,7 @@ handle_request("GET", "/test/get_network", #{<<"id">> := Id0}, _) ->
<<"name">> => <<"test2">>, <<"name">> => <<"test2">>,
<<"ipaddr">> => <<"10.211.180.0/24">>, <<"ipaddr">> => <<"10.211.180.0/24">>,
<<"owner_id">> => 1234, <<"owner_id">> => 1234,
<<"domain">> => <<"punchnet9.net">>,
<<"disabled_clients">> => [] <<"disabled_clients">> => []
}, },
10 => #{ 10 => #{
@ -61,6 +63,7 @@ handle_request("GET", "/test/get_network", #{<<"id">> := Id0}, _) ->
<<"name">> => <<"test3">>, <<"name">> => <<"test3">>,
<<"ipaddr">> => <<"10.211.181.0/24">>, <<"ipaddr">> => <<"10.211.181.0/24">>,
<<"owner_id">> => 1234, <<"owner_id">> => 1234,
<<"domain">> => <<"punchnet10.net">>,
<<"disabled_clients">> => [] <<"disabled_clients">> => []
} }
}, },

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}]}
]} ]}
]} ]}
]. ].