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

log4rs handle support #111

Open
tylerhawkes opened this issue Jan 7, 2019 · 5 comments
Open

log4rs handle support #111

tylerhawkes opened this issue Jan 7, 2019 · 5 comments

Comments

@tylerhawkes
Copy link

I'd like to be able to use sentry with log4rs while still being able to change the log4rs config. Currently I'm using log4rs and I dynamically reload the config whenever the file changes using inotify. To do this, the init function of log4rs returns a handle that I keep in a static mut. After looking at the examples and the code, I don't see how that's possible right now since the init call doesn't return anything. I'm happy to use any workarounds that might be available.

@bbigras
Copy link
Contributor

bbigras commented Feb 8, 2019

How do you use log4rs with sentry? With sentry::integrations::log? Do you have an example?

@mitsuhiko
Copy link
Member

You could make a proxy I assume. Sentry's log integration just dispatches to another logger.

@tylerhawkes
Copy link
Author

We don't use it yet, but are considering it. Even just an example of how to use it with something other than env logger would be great.

@msrd0
Copy link

msrd0 commented Mar 28, 2019

I'd like to see something with rust/log4rs similar to java/logback, where I can add sentry as an appender that will upload all messages with warn level or higher. Code could look similar to this:

let sentry = SentryAppender::builder()
		// ...
		.build();
	
let config = Config::builder()
		// ...
		.appender(Appender::builder().build("sentry", Box::new(sentry)))
		// ...
		.build(Root::builder().appender("sentry").build(LevelFilter::Warn))
		.unwrap();

@msrd0
Copy link

msrd0 commented May 12, 2019

I've now made https://crates.io/crates/log4rs-sentry to get the desired behaviour

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

4 participants