Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Fix broken syslog (#943)

Rich Turner20cf0bacc5d9
diff --git a/container/src/main/java/org/openremote/container/Container.java b/container/src/main/java/org/openremote/container/Container.java
index 0c60eb684..c5542af23 100644
--- a/container/src/main/java/org/openremote/container/Container.java
+++ b/container/src/main/java/org/openremote/container/Container.java
@@ -29,6 +29,8 @@ import org.openremote.model.util.ValueUtil;
import java.util.*;
import java.util.concurrent.ScheduledExecutorService;
+import java.util.logging.Handler;
+import java.util.logging.Logger;
import java.util.stream.Collectors;
import static java.lang.System.Logger.Level.*;
@@ -122,6 +124,14 @@ public class Container implements org.openremote.model.Container {
EXECUTOR_SERVICE = new NoShutdownScheduledExecutorService("Scheduled task", scheduledTasksThreadsMax);
+ // Any log handlers of the root logger that are container services must be registered
+ for (Handler handler : Logger.getLogger("").getHandlers()) {
+ if (handler instanceof ContainerService) {
+ ContainerService containerServiceLogHandler = (ContainerService) handler;
+ this.services.put(containerServiceLogHandler.getClass(), containerServiceLogHandler);
+ }
+ }
+
if (services != null) {
services.forEach(svc -> this.services.put(svc.getClass(), svc));
}