-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Add support for configuring lobgack logging via JMX #4486
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
Conversation
|
Thanks. Have you signed the CLA? |
|
See also #3819 - I'd rather have an actuator endpoint for that if possible (with something that works regardless of the logging system). |
|
@philwebb, yes, I did sign the CLA :) @snicoll, thanks for the #3819 reference. I remember seeing that issue a while ago, but couldn't find it probably because I was focused around the default (i.e. Logback) logging setup. Regarding actuator endpoint, does the suggested Also, concerning the other supported logging frameworks:
HTTP operations are easily enabled using Jolokia. WDYT? |
|
@vpavic Not yet. I've been on vacation :) |
|
Thanks for the reminder. I only meant to say that if we had something, we should add something based on the |
|
Any chance this makes the I'm also willing to work on a separate PR to provide the abstraction based endpoint, but I'm short of time ATM. |
|
I am not a huge fan of merging this one in the 1.3 line. The logging endpoint may actually be a mini-theme for 1.4 and if we merge this one now we'll have to maintain it in its current form. I'd rather give us enough space to improve it first (if necessary). |
|
It feels a little bit risky to add this to a point release. We've had some problems in the past where JMX beans clashed. There are already quite a lot of issues resolved for 1.3.1 so I'd rather defer some of the more risky ones. |
|
@vpavic We're thinking of porting the Spring Cloud feature that lets you configure logging level properties via JMX. If we did this, all logging system would get update support, but some of the other features exposed via What do you currently use |
|
Hi @philwebb - yes, we primarily use it for updating logger levels, however level getters and |
@philwebb could you provide some reference to this feature? Also having in mind previous comment:
Any chance this PR (or something similar) sees light in |
|
Any feedback on the previous comment? |
|
I am not super keen on deploying a logging-specific endpoint automatically at this point. I'd rather like to see a |
|
@snicoll thanks for your feedback. I'll try to put together a PR for Regarding the hook point you mentioned, I assume this would also be based on the logging abstraction, to provide customization regardless of the logging system used? |
|
I was more thinking of an hookpoint to allow you to register an extra MBean very easily. |
|
Closing in favor of #5321. |
|
@philwebb thanks for reconsidering this. FWIW I personally still highly prefer having native Logback JMX operations available, vs logging abstraction endpoint. This is not to say the logging abstraction endpoint has no use but IMO users familiar with Logback would probably also prefer native JMX. |
d1272f0 to
59437df
Compare
59437df to
885f9a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience on this PR @vpavic
Unfortunately, I am not keen to merge this PR in its current state, see my comments for more details.
Also, there is nothing that unregisters that MBean on shutdown of the context as far as I can see, which means the MBean would be hanging around if the process does not stop.
What happens if several applications run in the same VM? As far as I can see the first one to start would "win". If Logback is ready to make that kind of compromise if a different context name isn't provided, that is fine by me (and probably ok) but it certainly isn't for something that is done automatically.
I'd rather much logback do that stuff automatically and be accountable for rather than us doing it.
Thoughts?
| private void registerJmxConfigurator(LoggerContext loggerContext, | ||
| LoggingInitializationContext initializationContext, String configLocation, | ||
| LogFile logFile) { | ||
| String objectNameAsStr = MBeanUtil.getObjectNameFor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is duplicating code from LogBack which enables the MBean with a single line in its XML configuration. Shouldn't we try to reduce the amount of code on our side for this?
| public void testBasicConfigLocation() throws Exception { | ||
| this.loggingSystem.beforeInitialize(); | ||
| assertThat(getConsoleAppender()).isNotNull(); | ||
| assertThat(ManagementFactory.getPlatformMBeanServer().queryMBeans( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test this in a dedicated test. I'd like also to see a test that checks what happens if the MBean has already been registered (using the <jmxConfigurator /> option).
885f9a3 to
7cd0103
Compare
|
Thanks for the feedback @snicoll, I've updated the PR to address your test related concerns.
I'm not sure what exactly we can do about that since the code in subject, from
Not sure I follow this part. Logback's original |
Ask Logback to provide a public API that does the same thing as this XML would be a good start I think. It may not work but at least they'll be aware we have this need.
Sorry I had overlooked the listener stuff. This PR has missing tests then. If we do something automatically, we need to test what happens on shutdown, what happens when two apps are started in the same process, etc. Does that make sense? |
7cd0103 to
de996f8
Compare
|
I've opened LOGBACK-1371 and added a couple of test cases related to lifecycle related aspects. |
snicoll
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback @vpavic!
I am still not confident to merge this change so I've flagged it to see what the rest of the team thinks. I've also added a comment to the issue you've created to check if the Logback team would consider flipping the default.
| } | ||
|
|
||
| @Test | ||
| public void testTwoLoggingSystemsYieldSingleJmxConfigurator() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't consider this to be a good thing actually. Which logging configuration are you effectively managing with such setup? Is there a way to provide another name than default so that we get one MBean per app instead?
| <configuration> | ||
| <include resource="org/springframework/boot/logging/logback/defaults.xml"/> | ||
| <include resource="org/springframework/boot/logging/logback/console-appender.xml"/> | ||
| <jmxConfigurator/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd put this one first so that it is more explicit
|
FWIW, I share @snicoll's reservations. In particular, getting a single JXM configurator when there are multiple logging systems doesn't sound right to me. |
|
@vpavic given the discussion above, I don't think we can merge this and I haven't seen any progress on the logback issue you've created. If that changes, I am sure another PR will have to crafted anyway and I am more than happy to review it. |
|
Just to clarify - you're saying LOGBACK-1371 is a prerequisite for anything to be done on Spring Boot side? |
|
Yes. We could consider a new proposal that doesn't exhibit the problems we've raised in the last comment but I'd really prefer if Logback was providing a way to do this without us having to copy/paste code. Also, this is a problem because they don't do it by default and I'd rather have them take that responsibility for their own namespace than us. |
I agree that would be preferred - thanks for the feedback @snicoll. |
It would be nice to have support for modifying logging configuration in runtime using JMX.
This PR enables Logback's JMX Configurator as a part of default logging setup.
I've signed the CLA.