Truncate logs that is too long
This commit is contained in:
parent
bcbb4b68e9
commit
a8d2497480
|
@ -368,6 +368,12 @@ log.dir = {{ platform_log_dir }}
|
|||
## Default: emqx.log
|
||||
log.file = emqx.log
|
||||
|
||||
## Limits the total number of characters printed for each log event.
|
||||
##
|
||||
## Value: Integer
|
||||
## Default: 1024
|
||||
log.chars_limit = 1024
|
||||
|
||||
## Maximum size of each log file.
|
||||
##
|
||||
## Value: Number
|
||||
|
|
|
@ -420,6 +420,11 @@ end}.
|
|||
{datatype, file}
|
||||
]}.
|
||||
|
||||
{mapping, "log.chars_limit", "log.chars_limit", [
|
||||
{default, 1024},
|
||||
{datatype, integer}
|
||||
]}.
|
||||
|
||||
{mapping, "log.rotation.size", "kernel.logger", [
|
||||
{default, "10MB"},
|
||||
{datatype, bytesize}
|
||||
|
@ -464,6 +469,10 @@ end}.
|
|||
{translation, "kernel.logger", fun(Conf) ->
|
||||
LogTo = cuttlefish:conf_get("log.to", Conf),
|
||||
LogLevel = cuttlefish:conf_get("log.level", Conf),
|
||||
CharsLimit = case cuttlefish:conf_get("log.chars_limit", Conf) of
|
||||
-1 -> unlimited;
|
||||
V -> V
|
||||
end,
|
||||
Formatter = {emqx_logger_formatter,
|
||||
#{template =>
|
||||
[time," [",level,"] ",
|
||||
|
@ -474,7 +483,8 @@ end}.
|
|||
[{peername,
|
||||
[peername," "],
|
||||
[]}]},
|
||||
msg,"\n"]}},
|
||||
msg,"\n"],
|
||||
chars_limit => CharsLimit}},
|
||||
FileConf = fun(Filename) ->
|
||||
#{type => wrap,
|
||||
file => filename:join(cuttlefish:conf_get("log.dir", Conf), Filename),
|
||||
|
|
Loading…
Reference in New Issue