Skip to content

Conversation

@vpavic
Copy link
Contributor

@vpavic vpavic commented Nov 14, 2015

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.

@philwebb
Copy link
Member

Thanks. Have you signed the CLA?

@snicoll
Copy link
Member

snicoll commented Nov 14, 2015

See also #3819 - I'd rather have an actuator endpoint for that if possible (with something that works regardless of the logging system).

@vpavic
Copy link
Contributor Author

vpavic commented Nov 14, 2015

@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 LoggingEndpoint imply that all logging implementations would share the same set of operations? This would be somewhat limiting, since the users would not get the enitre set of operations for their logging framework of choice thus again needing to manually enable JMX support (for Logback at least, see below).

Also, concerning the other supported logging frameworks:

HTTP operations are easily enabled using Jolokia.

WDYT?

@vpavic
Copy link
Contributor Author

vpavic commented Nov 24, 2015

@philwebb, @snicoll, any thoughts on my previous comment?

@philwebb
Copy link
Member

@vpavic Not yet. I've been on vacation :)

@philwebb philwebb added the for: team-attention An issue we'd like other members of the team to review label Nov 24, 2015
@snicoll
Copy link
Member

snicoll commented Nov 25, 2015

Thanks for the reminder. I only meant to say that if we had something, we should add something based on the LoggingSystem (i.e. the abstraction). We could also deploy dedicated JMX endpoints when they are available though.

@wilkinsona wilkinsona added team-meeting and removed for: team-attention An issue we'd like other members of the team to review labels Nov 25, 2015
@vpavic
Copy link
Contributor Author

vpavic commented Dec 14, 2015

Any chance this makes the 1.3.1.RELEASE?

I'm also willing to work on a separate PR to provide the abstraction based endpoint, but I'm short of time ATM.

@snicoll
Copy link
Member

snicoll commented Dec 14, 2015

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).

@philwebb
Copy link
Member

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
Copy link
Contributor Author

vpavic commented Dec 14, 2015

@snicoll, @philwebb, note taken - thanks for your feedback!

@philwebb
Copy link
Member

philwebb commented Jan 6, 2016

@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 ch.qos.logback.classic.jmx.JMXConfiguratorMBean wouldn't be available.

What do you currently use JMXConfiguratorMBean for? Is it simply to update logger levels, or do you need the more advanced features such as reloadByURL?

@vpavic
Copy link
Contributor Author

vpavic commented Jan 6, 2016

Hi @philwebb - yes, we primarily use it for updating logger levels, however level getters and reloadDefaultConfiguration operations are often used as well.

@vpavic
Copy link
Contributor Author

vpavic commented Feb 3, 2016

We're thinking of porting the Spring Cloud feature that lets you configure logging level properties via JMX.

@philwebb could you provide some reference to this feature?

Also having in mind previous comment:

It feels a little bit risky to add this to a point release.

Any chance this PR (or something similar) sees light in 1.4.0? :)

@snicoll snicoll changed the title Add support for configuring logging via JMX Add support for configuring lobgack logging via JMX Feb 3, 2016
@vpavic
Copy link
Contributor Author

vpavic commented Feb 26, 2016

Any feedback on the previous comment?

@snicoll
Copy link
Member

snicoll commented Feb 29, 2016

I am not super keen on deploying a logging-specific endpoint automatically at this point. I'd rather like to see a LoggingEndpoint of some sort with some of the features that are exposed by the one provided by logback. One way to mitigate that if you still want that MBean to be deployed is some hook point that would allow you to easily register it.

@vpavic
Copy link
Contributor Author

vpavic commented Feb 29, 2016

@snicoll thanks for your feedback. I'll try to put together a PR for LoggingEndpoint shortly and see where that gets us.

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?

@snicoll
Copy link
Member

snicoll commented Feb 29, 2016

I was more thinking of an hookpoint to allow you to register an extra MBean very easily.

@vpavic vpavic mentioned this pull request Mar 3, 2016
@vpavic
Copy link
Contributor Author

vpavic commented Mar 3, 2016

Closing in favor of #5321.

@vpavic vpavic closed this Mar 3, 2016
@philwebb philwebb reopened this Mar 29, 2016
@philwebb
Copy link
Member

Since #5321 is on hold, I wonder if it is worth reconsidering this one. See also #5396

@philwebb philwebb added type: enhancement A general enhancement for: team-attention An issue we'd like other members of the team to review labels Mar 29, 2016
@vpavic
Copy link
Contributor Author

vpavic commented Mar 29, 2016

@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.

@vpavic vpavic force-pushed the logging-jmx-support branch from d1272f0 to 59437df Compare November 16, 2017 20:51
@philwebb philwebb added this to the 2.0.0.RC1 milestone Dec 8, 2017
@vpavic vpavic force-pushed the logging-jmx-support branch from 59437df to 885f9a3 Compare December 11, 2017 11:06
@snicoll snicoll self-assigned this Jan 8, 2018
Copy link
Member

@snicoll snicoll left a 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(
Copy link
Member

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(
Copy link
Member

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).

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Jan 9, 2018
@vpavic vpavic force-pushed the logging-jmx-support branch from 885f9a3 to 7cd0103 Compare January 12, 2018 07:43
@vpavic
Copy link
Contributor Author

vpavic commented Jan 12, 2018

Thanks for the feedback @snicoll, I've updated the PR to address your test related concerns.

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?

I'm not sure what exactly we can do about that since the code in subject, from ch.qos.logback.classic.gaffer.ConfigurationDelegate, isn't quite structured in a reusable manner. Did you have something specific in mind? My original idea was to keep the registration code as close as possible to Logback's, since that way we detect if JMXConfigurator was already registered via XML.

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.

Not sure I follow this part. Logback's original JMXConfigurator already implements LoggerContextListener and registers itself with the LoggerContext, thus handling the lifecycle events and unregistration. By extending the JMXConfigurator with our specific implementation we do the same.

@snicoll
Copy link
Member

snicoll commented Jan 12, 2018

I'm not sure what exactly we can do about that

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.

Not sure I follow this part.

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?

@vpavic vpavic force-pushed the logging-jmx-support branch from 7cd0103 to de996f8 Compare January 15, 2018 07:24
@vpavic
Copy link
Contributor Author

vpavic commented Jan 15, 2018

I've opened LOGBACK-1371 and added a couple of test cases related to lifecycle related aspects.

@snicoll snicoll added for: team-attention An issue we'd like other members of the team to review and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 15, 2018
Copy link
Member

@snicoll snicoll left a 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 {
Copy link
Member

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/>
Copy link
Member

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

@snicoll snicoll removed their assignment Jan 16, 2018
@wilkinsona
Copy link
Member

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.

@snicoll snicoll modified the milestones: 2.0.0.RC1, 2.1.0 Jan 17, 2018
@snicoll snicoll removed the for: team-attention An issue we'd like other members of the team to review label Jan 17, 2018
@snicoll
Copy link
Member

snicoll commented May 18, 2018

@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.

@snicoll snicoll closed this May 18, 2018
@snicoll snicoll removed this from the Icebox milestone May 18, 2018
@snicoll snicoll added status: declined A suggestion or change that we don't feel we should currently apply and removed type: enhancement A general enhancement labels May 18, 2018
@vpavic
Copy link
Contributor Author

vpavic commented May 21, 2018

Just to clarify - you're saying LOGBACK-1371 is a prerequisite for anything to be done on Spring Boot side?

@snicoll
Copy link
Member

snicoll commented May 21, 2018

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.

@vpavic
Copy link
Contributor Author

vpavic commented May 21, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants