-
Notifications
You must be signed in to change notification settings - Fork 123
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
Hard to find how to define logging level for system backend #160
Comments
The system backend uses JDK logger, so just set the log level of the equivalently named JDK logger or parent logger. Using a logging.properties file is best. http://tutorials.jenkov.com/java-logging/configuration.html Currently Flogger is agnostic to how log levels are set and deliberately doesn't offer an API (since a different backend might treat log levels completely differently).At some point I might rethink what "controlling logging" means, but that's a very big effort and I don't have time, so for now you have to set logging levels according to the chosen backend in the system. This makes it hard for random classes to change logging configuration programmatically, but personally I think that's something they should not be doing anyway (logging config should be set up by the outer logic in an application or via system properties, where the logger backend is known). |
Thanks! Does it make sense to point that in the easy-to-find documentation? |
Yeah, that's a good point, I'll add something to the top level docs. It's always hard to remember to document the things your code doesn't do :) |
I'm also having a hard time figuring out how to configure flogger properly. I've migrated a huge codebase from slf4j to flogger, and for some reason when running tests none of the debug logs are being emitted. Code that previously looked like this just worked:
but after replacing with:
the logs are not emitting when running tests. Only logs Same issue with tests in junit and testng. |
Which logging backed are you using? The JDK logger based "system" backend uses INFO as the default log level, so it's expected that "fine" logging will be suppressed unless you use that standard JDK logging configuration mechanisms to change that. |
It's using log4j as far as I know. This is also reproducible on the Gerrit project. See this issue. Gerrit sets up the log like this, using Apache log4j's log manager:
Logs using flogger's I suspect it's something missing (or wrong) in the configuration, but I'm not really sure where to look. |
If it's using Log4J, then I'm afraid I can't help you. The Log4J backend is community supported and not something I understand at all really. What I can tell you is that the "core" Flogger code never tries to decide whether to log or not, it always just calls the backend to get that. My guess is still that it's actually using the JDK backend, since the observed changes in behaviour fit that idea exactly. |
I've just posted an update on that issue with some more findings. It looks like the settings that are done by the |
As I said, if it's using log4J, then it's a log4J backend bug (which I can't really help with) and if it's using the JDK logger backend then it's expected behaviour (since you aren't doing anything special to enable "fine" logging). Why not just run the code in a debugger and see at what point a log statement is "dropped", and which classes are being loaded/used in the backend? This won't be hard to track down. |
The issue with Gerrit has been fixed by @davido |
I spent a fair amount of time trying to find how to set logging level for system backend. I failed and I gave up. Is there is a knob for that, mind making it easier to find or state it is not possible for system backend?
The text was updated successfully, but these errors were encountered: