-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Build time minimum log level #13376
Build time minimum log level #13376
Conversation
Thanks for your pull request! The title of your pull request does not follow our editorial rules. Could you have a look?
|
One problem with setting the default Maybe you can log a warning when the runtime level is lower than the build-time min-level. |
Agreed! To be fair that's the kind of warning you get when attempting to changinge a build-time option in Quarkus at runtime; this should be consistent with that. I believe there also was a recent PR to make such a warning ugpraded to a failure to start - which greatly helps in certain testing and IT tests. @ppalaga , I don't seem able to find it - could you point @galderz to the right code? |
It is in this PR #13154 |
@danberindei Agreed, I'll look into adding that warning. I'm working to finish up this PR (add unit tests and documentation) next few days. I did some benchmarking with Infinispan native server and this change had a consistent positive impact. In Infinispan's case, it was combined with removing static and instance level cache of static calls to isTraceEnabled/isDebugEnabled. This calls are fast and can just be done in the code directly. |
Ignore CI failures until done, I'm pushing temporary commits to add unit testing :) |
@danberindei @Sanne I've looked at the warning, but I'm hesitant to add it at this stage since I'm unsure how to best deal with it. I don't want to have the gizmo generated code for the substituted |
Did you check my previous suggestion? ^ I don't remember where this code lives and how it works, but I believe we already have a similar check for build-time configuration properties - including JVM mode. Please have a look at that and try making this consistent with it? |
The warning should probably happen as a config validation when logging sets up each log category and handler at run time. That code already needs to clamp the log level to the |
36ffe3f
to
a0f4beb
Compare
This is ready now. I've ended up creating 2 integration test projects. One tests the logic when no Also added some light touches to the logging documentation. |
Once it's been approved I'll go ahead and squash the commits. |
Looking into CI results, the failures seem to be caused by the PR itself. |
@gsmet Addressed comments, squashed and pushed. |
* It enables log levels below that to be folded in native. * Runtime min-level has been removed (was deprecated already).
ffe7741
to
f5c4cad
Compare
Rebased to fix a conflict and get CI to run again. |
OK let's get this in then. Thanks. |
Thx all! |
I just try Quarkus 1.11 and now my debug logs didn't show anymore due to this PR. Logging level is something that everybody set at runtime to have different log levels on different environements, so it feels wrong to me that this is a build time property. I understand that it causes an issue on native but maybe a native only solution could has been found (like a specific native build prop). Sorry to give feedback late but I really think this change will surprised a lot of people and I wanted to give awardeness to it. |
Right, but you should have seen a warning message in the console saying that the DEBUG level was promoted to INFO because the min-level is INFO.
It's quite common to have debug builds of native executables. The idea is that you have a production one with no debug, and one that has been built with debug/trace min-level for when you want to debug things.
Surprise that DEBUG is not there yeah, but the warning message should be there.
Doing this creates the opposite problem: for native I need to pass extra X property whereas for jvm mode I don't. With the information we have so far, we decided to keep things as consistent as possible between the two modes. |
@galderz I assume this change has some memory/cpu impact - can we quantify it a bit as otherwise this does seem like a bit unfortunate UX wise. |
@maxandersen You can find numbers in this Infinispan PR. The optimisations introduced by this PR increase throughput around 10-15%. |
Excellent, thanks @galderz ! 10-15% is worth it and we seem to log/warn where ever detectable. |
This is only when running with Infinispan or other extensions that uses TRACE level logs. Most applications should suffer no performance penaly.
This log message should at least provides the right configuration option to use (in my case it was quarkus.log.console.min-level I think).
True, but it's very un-common to have debug builds of JVM applications ...
I would prefere this one as most application / developer I've talk about Quarkus with still deploy Quarkus on JVM (80 to 90% of them I think) but maybe my experience is not significative. |
We use TRACE extensively in many libraries, including Hibernate ORM,
transaction manager, drivers.
Galder's patches are very welcome as they fix several long standing
performance issues which we identified since during the early Protean
prototypes.
…On Tue, 19 Jan 2021, 12:54 Loïc Mathieu, ***@***.***> wrote:
@maxandersen <https://github.com/maxandersen>
Excellent, thanks @galderz <https://github.com/galderz> ! 10-15% is worth
it and we seem to log/warn where ever detectable.
This is only when running with Infinispan or other extensions that uses
TRACE level logs. Most applications should suffer no performance penaly.
Right, but you should have seen a warning message in the console saying
that the DEBUG level was promoted to INFO because the min-level is INFO.
This log message should at least provides the right configuration option
to use (in my case it was quarkus.log.console.min-level I think).
It's quite common to have debug builds of native executables.
True, but it's very un-common to have debug builds of JVM applications ...
Doing this creates the opposite problem: for native I need to pass extra X
property whereas for jvm mode I don't.
I would prefere this one as most application / developer I've talk about
Quarkus with still deploy Quarkus on JVM (80 to 90% of them I think) but
maybe my experience is not significative.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#13376 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAKMTNTTNMXJAUJCEFGYL3S2V6GTANCNFSM4T3IOJSA>
.
|
I think the argument is not necessarily for including trace in min-level but make it DEBUG. Would that be a compromise that removes trace from hotspots but still allow easy debugging while users who can benefit than set min-level to info ? Or is the belief the majority of 10-15% gain was from stripping out debug ? |
Each level would be arbitrary, I usually use INFO on production and turn on DEBUG only when needed (local for some part of the code, at the moment also on our integration env because we are in the rampdown phase of our apps). But I now some people use DEBUG in production, and other uses WARNING ! And some people never use TRACE (like myself) and other logs everything at INFO ... For me, DEBUG is better but it's only my usage of log level. |
From the perspective of Infinispan, changing the default min-level to DEBUG doesn't impact performance at all: we don't log a lot of DEBUG messages, and all per-request log messages are TRACE. However, I am aware of libraries we use/have used that use DEBUG/FINE as we use TRACE, e.g. okhttp. @galderz since we no longer use a |
@danberindei When
That's an interesting angle. TBH, I don't really mind what the default value for When it comes to Infinispan Native Server POV perspective, you're free to set the default |
FAO @dmlloyd @Sanne. This is a follow up to #13102 PR. Closes #12938.
It adds a new optional build time per category configuration called
min-level
. It controls the minimum level of logging defined at build time.By default all categories'
min-level
is set toINFO
, in which case the code generates an substratevm substitution that foldsisTraceEnabled
andisDebugEnabled
calls to returnfalse
.To keep things simple, the moment any
min-level
is configured, a different substitution is created that computes whether a given log level is enabled based on a combination of both themin-level
set and the runtime loglevel
. So, as an example, if you want to getTRACE
on a given category, sayorg.example.table
, you need to provide both:quarkus.log.category."org.example.table".min-level=TRACE
quarkus.log.category."org.example.table".level=TRACE
When deciding the logic 👆, I pondered about the need for the runtime log level to be set, but it felt awkward to have code that had been built with
min-level
set to TRACE, and runtime log level to be sayINFO
and forisTraceEnabled
to return true but nothing be logged when callinglog.trace
.To exercise this, I've been using this project to test the behaviour when no
min-level
has been set, and this other with the example above. I'd like to convert these two into Quarkus integration tests, but first I'd like to make sure we have agreement on the logic.Further optimisations are also applicable:
min-level
set in config areINFO
or above, the same logic as with nomin-level
set could be applied. The momentmin-level
is configured, the current logic does attempt to fold any calls.min-level
set in config areWARN
or above and the logic in 👆 was applied, one could also foldisInfoEnabled
calls to false.Unit testing wise, I had the following doubt: to test both the branches of the logic (no
min-level
set and amin-level
set to TRACE or some other), it seems to me that I'd need 2 maven integration test projects. Is that right? Could it be somehow done in a single one? Not sure...Aside from unit testing, and possible further optimisations, documentation needs to be updated.