100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Fix log rotation not working (#2498)
Wouter Born78838ac6b414
diff --git a/container/src/main/java/org/openremote/container/util/LoggingFileHandler.java b/container/src/main/java/org/openremote/container/util/LoggingFileHandler.javaindex 65f03d681..db7fbb887 100644--- a/container/src/main/java/org/openremote/container/util/LoggingFileHandler.java+++ b/container/src/main/java/org/openremote/container/util/LoggingFileHandler.java@@ -28,13 +28,36 @@ import java.util.logging.LogManager;*/public class LoggingFileHandler extends FileHandler {- private static String pattern() throws IOException {- String prefix = LoggingFileHandler.class.getName();- String v = LogManager.getLogManager().getProperty(prefix +".pattern");- return v.replace("${" + LogUtil.OR_LOGGING_PROPERTY_NAME + "}", System.getProperty(LogUtil.OR_LOGGING_PROPERTY_NAME));+ private static String getProperty(String propertyName) {+ return LogManager.getLogManager().getProperty(LoggingFileHandler.class.getName() + propertyName);+ }++ private static int getIntProperty(String propertyName, int defaultValue) {+ String val = getProperty(propertyName);+ if (val == null) {+ return defaultValue;+ }+ try {+ return Integer.parseInt(val.trim());+ } catch (Exception e) {+ return defaultValue;+ }+ }++ private static int count() {+ return Math.max(1, getIntProperty(".count", 1));+ }++ private static int limit() {+ return Math.max(0, getIntProperty(".limit", 0));+ }++ private static String pattern() {+ return getProperty(".pattern").replace("${" + LogUtil.OR_LOGGING_PROPERTY_NAME + "}", System.getProperty(LogUtil.OR_LOGGING_PROPERTY_NAME));}public LoggingFileHandler() throws IOException {- super(pattern());+ // The FileHandler(String) constructor cannot be used because this constructor sets the limit and count after configuration.+ super(pattern(), limit(), count());}}