erlang-lager / lager

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

when change pwd, RelPath will also change, and create new log file in new dir #534

Closed yidayoung closed 3 years ago

yidayoung commented 3 years ago

with env

{lager, [
        {log_root, "./log"},
        {crash_log, "crash.log"}
    ]
    },

after call cd("log"). crash log will make new file in ./log/log/crash.log not continue write in ./log/crash.log seems because when ensure log file,use rel file name,and rel file changed because of pwd changed https://github.com/erlang-lager/lager/blob/91575d4479c897451edf138c10fa86c3125ec52e/src/lager_util.erl#L601-L604 then will create new log file https://github.com/erlang-lager/lager/blob/91575d4479c897451edf138c10fa86c3125ec52e/src/lager_rotator_default.erl#L44-L47

same behavior in lager_file_backend, not sure this is mean to. if not seems just change laget_util:expand_path from rel path to abs will resolve this,if this is fine,i could make a pr for this.

if mean to, maybe add a env key like use_abs_path or abs_log_root let config control is a way too

jadeallenx commented 3 years ago

Hi, I'd be glad to review a PR to fix this issue, thanks!