use of ch.qos.logback.classic.jmx.JMXConfigurator in project dropwizard by dropwizard.
the class DefaultLoggingFactory method configure.
@Override
public void configure(MetricRegistry metricRegistry, String name) {
LoggingUtil.hijackJDKLogging();
CHANGE_LOGGER_CONTEXT_LOCK.lock();
final Logger root;
try {
root = configureLoggers(name);
} finally {
CHANGE_LOGGER_CONTEXT_LOCK.unlock();
}
final LevelFilterFactory<ILoggingEvent> levelFilterFactory = new ThresholdLevelFilterFactory();
final AsyncAppenderFactory<ILoggingEvent> asyncAppenderFactory = new AsyncLoggingEventAppenderFactory();
final LayoutFactory<ILoggingEvent> layoutFactory = new DropwizardLayoutFactory();
for (AppenderFactory<ILoggingEvent> output : appenders) {
root.addAppender(output.build(loggerContext, name, layoutFactory, levelFilterFactory, asyncAppenderFactory));
}
StatusPrinter.setPrintStream(configurationErrorsStream);
try {
StatusPrinter.printIfErrorsOccured(loggerContext);
} finally {
StatusPrinter.setPrintStream(System.out);
}
final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
MBEAN_REGISTRATION_LOCK.lock();
try {
final ObjectName objectName = new ObjectName("io.dropwizard:type=Logging");
if (!server.isRegistered(objectName)) {
server.registerMBean(new JMXConfigurator(loggerContext, server, objectName), objectName);
}
} catch (MalformedObjectNameException | InstanceAlreadyExistsException | NotCompliantMBeanException | MBeanRegistrationException e) {
throw new RuntimeException(e);
} finally {
MBEAN_REGISTRATION_LOCK.unlock();
}
configureInstrumentation(root, metricRegistry);
}
Aggregations