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

attempted to set a logger after the logging system was already initialized #122

Open
goodidea-kp opened this issue Mar 18, 2023 · 3 comments

Comments

@goodidea-kp
Copy link

I am getting the error: attempted to set a logger after the logging system was already initialized Logging is not working. How to fix it?
Only 1 occurrence in my code, but runs from async function.

  • simplelog = 0.12.1
  • log = 0.4.17
match CombinedLogger::init(vec![
            TermLogger::new(
                LevelFilter::Warn,
                simplelog::Config::default(),
                TerminalMode::Mixed,
                ColorChoice::Auto,
            ),
            WriteLogger::new(LevelFilter::Trace, simplelog::Config::default(), logger),
        ]) {
            Ok(v) => (),
            Err(err) => println!("Log err:{}", err.to_string()),
        };
@Drakulix
Copy link
Owner

Unable to tell from that small code sample.

I would suggest to attach a debugger, set a breakpoint at CombinedLogger::init and check if it really is only called once.

If it is some other crate might be initializing the log-infrastructure. In that case put a breakpoint at log::set_global_logger and figure out throw backtraces, which other crate is interfering here.

@goodidea-kp
Copy link
Author

goodidea-kp commented Mar 19, 2023

My code is deployed as Docker Compose for now. Any help on how to attach a debugger on the remote? How to run the Rust app in debug mode? I know how to do it on Java, but not sure I know how to do remote debugging on Rust. I can see the terminal console very well, but the file is empty. Permissions on file structure? Not sure how to debug. Please advise...

@Drakulix
Copy link
Owner

My code is deployed as Docker Compose for now. Any help on how to attach a debugger on the remote?

I am sorry, but this is a repository for a logging library, I am not here to offer general support on linux deployment and configuration.

gdb needs to run on the system the executable is running and since you want to attach at launch it would likely need to run inside the container.
I strongly advise to test your application outside of docker for debugging.

How to run the Rust app in debug mode?

Compile without --release. If you compile this application as part of a larger build system, that depends.

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

2 participants