|
30 | 30 | import java.util.concurrent.TimeUnit; |
31 | 31 | import java.util.function.Function; |
32 | 32 |
|
| 33 | +import ch.qos.logback.classic.LoggerContext; |
| 34 | +import ch.qos.logback.classic.joran.JoranConfigurator; |
| 35 | +import ch.qos.logback.core.joran.spi.JoranException; |
| 36 | +import ch.qos.logback.core.util.StatusPrinter; |
33 | 37 | import com.rabbitmq.client.impl.ClientVersion; |
34 | 38 | import com.rabbitmq.client.impl.nio.NioParams; |
35 | 39 | import io.micrometer.core.instrument.MeterRegistry; |
@@ -340,10 +344,29 @@ static MulticastSet.CompletionHandler getCompletionHandler(MulticastParams p) { |
340 | 344 | return completionHandler; |
341 | 345 | } |
342 | 346 |
|
343 | | - public static void main(String[] args) { |
| 347 | + public static void main(String[] args) throws IOException { |
| 348 | + configureLogbackIfNecessary(); |
344 | 349 | main(args, new PerfTestOptions().setSystemExiter(new JvmSystemExiter()).setSkipSslContextConfiguration(false)); |
345 | 350 | } |
346 | 351 |
|
| 352 | + private static void configureLogbackIfNecessary() throws IOException { |
| 353 | + if (System.getProperty("logback.configurationFile") == null) { |
| 354 | + LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); |
| 355 | + InputStream configurationFile = PerfTest.class.getResourceAsStream("/logback-perf-test.xml"); |
| 356 | + try { |
| 357 | + JoranConfigurator configurator = new JoranConfigurator(); |
| 358 | + configurator.setContext(context); |
| 359 | + context.reset(); |
| 360 | + configurator.doConfigure(configurationFile); |
| 361 | + } catch (JoranException je) { |
| 362 | + // StatusPrinter will handle this |
| 363 | + } finally { |
| 364 | + configurationFile.close(); |
| 365 | + } |
| 366 | + StatusPrinter.printInCaseOfErrorsOrWarnings(context); |
| 367 | + } |
| 368 | + } |
| 369 | + |
347 | 370 | private static SSLContext getSslContextIfNecessary(CommandLineProxy cmd, Properties systemProperties) throws NoSuchAlgorithmException { |
348 | 371 | SSLContext sslContext = null; |
349 | 372 | if (hasOption(cmd, "udsc") || hasOption(cmd,"useDefaultSslContext")) { |
|
0 commit comments