Log4rs: the `toml` feature is required for TOML support


#1

I’m trying to switch from env_logger to log4rs in a project.

I’ve added the dependency to log4rs in my Cargo.toml.

When I call the log4rs initializer (log4rs::init_file) from main I get the following:

thread ‘’ panicked at ‘called Result::unwrap() on an Err value: Log4rs(StringError(“the toml feature is required for TOML support”))’, …/src/libcore/result.rs:688

due to this in log4rs:

log4rs/blob/master/src/lib.rs

#[cfg(not(feature = “toml”))]
Some(“toml”) => Err(“the toml feature is required for TOML support”.into()),

Not sure what step I’m missing. Any hints appreciated.


#2

In your Cargo.toml under [dependencies], instead of

log4rs = VERSION

write:

log4rs = { version = VERSION, features = [toml] }

#3

Yes, that makes sense (and it worked). Thanks!


#4

Tried it and got something similar working, but I had to change one thing:

log4rs = { version = VERSION, features = [“toml”] }

i.e. the list of features must be an array of proper quoted strings. At least for me, rustc 1.9.0 (e4e8b6668 2016-05-18) and cargo 0.10.0-nightly (10ddd7d 2016-04-08)


#5

Yes, forgot to mention that I had added quotes.