Created
May 12, 2016 10:01
-
-
Save gronono/341cffa694642891d2f695a88a48e4f3 to your computer and use it in GitHub Desktop.
LogBack start JMXConfigurator without XML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class LogbackConfig { | |
@Autowired | |
private MBeanServer mbeanServer; | |
@PostConstruct | |
public void registerJmxConfigurator() throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException { | |
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); | |
ObjectName objectName = new ObjectName(MBeanUtil.getObjectNameFor(loggerContext.getName(), JMXConfigurator.class)); | |
JMXConfigurator jc = new JMXConfigurator(loggerContext, mbeanServer, objectName); | |
mbeanServer.registerMBean(jc, objectName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment