Skip to content

Configured level filters aren't respected in combined loggers #159

@Calandiel

Description

@Calandiel

Consider the following code:

	let config = ConfigBuilder::default()
		.set_time_level(LevelFilter::Error)
		.set_location_level(LevelFilter::Error)
		.build();
	let _ = CombinedLogger::init(vec![
		TermLogger::new(
			LevelFilter::Trace,
			config.clone(),
			TerminalMode::Mixed,
			ColorChoice::Auto,
		),
		WriteLogger::new(
			LevelFilter::Trace,
			config,
			File::create("file.log").expect("Failed to create a file logger!"),
		),
	])
	.expect("Failed to create a combined logger!");

It will print time level and location data for all message levels (not just error). The only way I found to modify the behavior was to use the Off level, which does turn it off but it does so for all levels, which is quite different and nowhere near as useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions