diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index cbed55f76..5f65db3c5 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -5,6 +5,9 @@
+
+
+
@@ -42,5 +45,8 @@
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/hivemq/HiveMQServer.java b/src/main/java/com/hivemq/HiveMQServer.java
index 5f8873821..2fcb7760a 100644
--- a/src/main/java/com/hivemq/HiveMQServer.java
+++ b/src/main/java/com/hivemq/HiveMQServer.java
@@ -66,18 +66,20 @@ public class HiveMQServer {
private final @NotNull SystemInformation systemInformation;
private final @NotNull MetricRegistry metricRegistry;
private final boolean migrate;
+ private final boolean loggingBootstrapEnabled;
private @Nullable Injector injector;
private @Nullable FullConfigurationService configService;
public HiveMQServer() {
- this(new SystemInformationImpl(true), new MetricRegistry(), null, true);
+ this(new SystemInformationImpl(true), new MetricRegistry(), null, true, true);
}
public HiveMQServer(
final @NotNull SystemInformation systemInformation,
final @Nullable MetricRegistry metricRegistry,
final @Nullable FullConfigurationService configService,
+ final boolean loggingBootstrapEnabled,
final boolean migrate) {
hivemqId = new HivemqId();
lifecycleModule = new LifecycleModule();
@@ -85,6 +87,7 @@ public HiveMQServer(
this.systemInformation = systemInformation;
this.metricRegistry = metricRegistry;
this.configService = configService;
+ this.loggingBootstrapEnabled = loggingBootstrapEnabled;
this.migrate = migrate;
}
@@ -105,7 +108,9 @@ public void bootstrap() throws Exception {
metricRegistry.addListener(new MetricRegistryLogger());
- LoggingBootstrap.prepareLogging();
+ if (loggingBootstrapEnabled) {
+ LoggingBootstrap.prepareLogging();
+ }
log.info("Starting HiveMQ Community Edition Server");
@@ -117,7 +122,10 @@ public void bootstrap() throws Exception {
}
log.trace("Initializing Logging");
- LoggingBootstrap.initLogging(systemInformation.getConfigFolder());
+
+ if (loggingBootstrapEnabled) {
+ LoggingBootstrap.initLogging(systemInformation.getConfigFolder());
+ }
log.trace("Initializing Exception handlers");
HiveMQExceptionHandlerBootstrap.addUnrecoverableExceptionHandler();
@@ -216,7 +224,10 @@ public void startInstance(final @Nullable EmbeddedExtension embeddedExtension) t
/* It's important that we are modifying the log levels after Guice is initialized,
otherwise this somehow interferes with Singleton creation */
- LoggingBootstrap.addLoglevelModifiers();
+ if (loggingBootstrapEnabled) {
+ LoggingBootstrap.addLoglevelModifiers();
+ }
+
instance.start(embeddedExtension);
}
@@ -262,7 +273,9 @@ public void stop() {
if (configService.persistenceConfigurationService().getMode() == PersistenceMode.FILE) {
dataLock.unlock();
}
- LoggingBootstrap.resetLogging();
+ if (loggingBootstrapEnabled) {
+ LoggingBootstrap.resetLogging();
+ }
}
public @Nullable Injector getInjector() {
diff --git a/src/main/java/com/hivemq/configuration/SystemProperties.java b/src/main/java/com/hivemq/configuration/SystemProperties.java
index b01c6d494..3601b991b 100644
--- a/src/main/java/com/hivemq/configuration/SystemProperties.java
+++ b/src/main/java/com/hivemq/configuration/SystemProperties.java
@@ -31,4 +31,6 @@ public class SystemProperties {
public static final String EXTENSIONS_FOLDER = "hivemq.extensions.folder";
public static final String DIAGNOSTIC_MODE = "diagnosticMode";
+
+ public static final String EMBEDDED_LOG_BOOTSTRAP_DISABLED = "hivemq.embedded.log.bootstrap.disabled";
}
diff --git a/src/main/java/com/hivemq/embedded/internal/EmbeddedHiveMQImpl.java b/src/main/java/com/hivemq/embedded/internal/EmbeddedHiveMQImpl.java
index de55b89ea..e1ff4d390 100644
--- a/src/main/java/com/hivemq/embedded/internal/EmbeddedHiveMQImpl.java
+++ b/src/main/java/com/hivemq/embedded/internal/EmbeddedHiveMQImpl.java
@@ -21,6 +21,7 @@
import com.google.inject.Injector;
import com.hivemq.HiveMQServer;
import com.hivemq.configuration.ConfigurationBootstrap;
+import com.hivemq.configuration.SystemProperties;
import com.hivemq.configuration.info.SystemInformationImpl;
import com.hivemq.configuration.service.FullConfigurationService;
import com.hivemq.configuration.service.InternalConfigurations;
@@ -50,6 +51,9 @@ class EmbeddedHiveMQImpl implements EmbeddedHiveMQ {
private final @NotNull SystemInformationImpl systemInformation;
private final @NotNull MetricRegistry metricRegistry;
+ private final @NotNull boolean loggingBootstrapEnabled =
+ !Boolean.parseBoolean(System.getProperty(SystemProperties.EMBEDDED_LOG_BOOTSTRAP_DISABLED, "false"));
+
@VisibleForTesting
final @NotNull ExecutorService stateChangeExecutor;
private final @Nullable EmbeddedExtension embeddedExtension;
@@ -146,7 +150,7 @@ private void stateChange() {
systemInformation.init();
configurationService = ConfigurationBootstrap.bootstrapConfig(systemInformation);
- hiveMQServer = new HiveMQServer(systemInformation, metricRegistry, configurationService, false);
+ hiveMQServer = new HiveMQServer(systemInformation, metricRegistry, configurationService, loggingBootstrapEnabled, false);
hiveMQServer.bootstrap();
hiveMQServer.startInstance(embeddedExtension);