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

Question: Is it possible to initialize logging via a configuration file? #60

Open
apatniv opened this issue May 23, 2020 · 3 comments
Open

Comments

@apatniv
Copy link

apatniv commented May 23, 2020

I don't see any example of this in docs.rs.

Thanks for writing a very useful library.

@daboross
Copy link
Owner

daboross commented May 24, 2020

This isn't a feature of fern - it only offers rust-syntax-based initialization.

log4rs is the best configuration-based logger I know of today. If you need it, one-way interop should be possible by passing a Box<dyn Log> created from log4rs into fern::Dispatch::chain.

Another alternative is to build your own configuration, and translate that into fern calls. This is probably substantially more work, but if you just need something simple like setting the maximum log level, it should be doable.

Glad the library has been useful! :)

@apatniv
Copy link
Author

apatniv commented May 24, 2020

Thanks for the response. I will look into your suggestions.

Do you think adding support for this in the future is a good idea?

@daboross
Copy link
Owner

In my view, I think it would be more work than what it's worth.

Fern does a relatively good job at its two jobs: first, a logging implementation, and second, an rusty interface to configure that implementation. If we added a configuration-based interface, then it could use the implementation, but it'd probably be completely separate from the rusty interface. I don't think that fern's implementation is anything that special, so there wouldn't be too much benefit over configuration interfaces which already exist, like log4rs.

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