Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support multiple process use same log file #28

Open
chenfengyuan opened this issue Dec 14, 2023 · 0 comments
Open

support multiple process use same log file #28

chenfengyuan opened this issue Dec 14, 2023 · 0 comments

Comments

@chenfengyuan
Copy link

let mut config = fast_log::Config::new()
        .custom(ConsoleErrAppender {})
        .file_split(
            file_path,
            fast_log::consts::LogSize::MB(log_file_mb),
            fast_log::plugin::file_split::RollingType::KeepNum(log_file_keep_num.into()),
            LogPacker {},
        )
        .level(log::LevelFilter::Info);
    config.format = Box::new(MyLogFormat {});
    fast_log::init(config).expect("failed to init log");

Currently fast_log will open file with read + write, and seek to the file end, and write logs to file.
When multiple process use same log file, it will result in repeated overwriting same position.
Opening the file using append can solve this problem.
But additional code may be needed to determine when to roll the file and synchronize this state between multiple processes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant