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

Logging always goes to redirected file. #401

Open
jmigual opened this issue Dec 11, 2024 · 2 comments
Open

Logging always goes to redirected file. #401

jmigual opened this issue Dec 11, 2024 · 2 comments

Comments

@jmigual
Copy link

jmigual commented Dec 11, 2024

I have the following config:

let my_level = LevelFilter::Debug;

let mut root_builder = Root::builder().appender("stderr");

let stdout = ConsoleAppender::builder()
    .target(Target::Stderr)
    .encoder(Box::new(PatternEncoder::new(
        "{d(%Y-%m-%d %H:%M:%S)} {h({l})} {t}: {m}{n}",
    )))
    .build();
let mut config_builder = LogConfig::builder().appender(
    Appender::builder()
        .filter(Box::new(ThresholdFilter::new((&my_level).into())))
        .build("stderr", Box::new(stdout)),
);

let root = root_builder.build(LevelFilter::Trace);
let handle = log4rs::init_config(config_builder.build(root)?)?;

Now, I've tried to run my program in Windows in the following ways:

  1. ./myprogram > stdout.log
  2. ./myprogram 2> stderr.log
  3. ./myprogram > stdout.log 2> stderr.log

In both versions 1 and 2, the logging is written to the output log file and not to the console. Version 3 is as expected, and the logging is only written to stderr.log.

@bconn98
Copy link
Collaborator

bconn98 commented Dec 31, 2024

I'll need to test this on my Windows 10 machine when I get it back up and running. Are you running on Windows 10 or 11?

@jmigual
Copy link
Author

jmigual commented Dec 31, 2024

Windows 11 23H2

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

No branches or pull requests

2 participants