erlang-lager / lager

A logging framework for Erlang/OTP
Apache License 2.0
1.12k stars 456 forks source link

add support settings to specify multiple logging levels #549

Open dong50252409 opened 3 years ago

dong50252409 commented 3 years ago

multiple log levels are supported for setting, like to {lager_file_backend, {file, "info.log"}, {level, [debug, error, notice]} } here's the issues #548

dong50252409 commented 3 years ago

The logging level can be specified this way in the configuration

{handlers, [
    {lager_console_backend,[
        {level, debug}          % Outputs all log levels to the console
    ]},
    {lager_file_backend, [
        {file, "info.log"},     % The info.log file only records logs at the levels of DEBUG, INFO, NOTICE, AND WARNING
        {level, [debug, info, notice, warning]}  
    ]},
    {lager_file_backend, [
        {file, "error.log"},    % The error.log records contains all logging levels above ERROR
        {level, error}
    ]}
]}.

You can also set the log level you want to view in the console like this

lager:set_loglevel(lager_console_backend, [info, notice]).