mirror of
https://github.com/Qortal/qortal.git
synced 2025-07-23 04:36:50 +00:00
Updated log4j to 2.17.1
This involves modifying the log4j2.properties file on node startup to fix an incompatibility with ${dirname:-}. Thanks to AlphaX Projects for tracking down this incompatibility.
This commit is contained in:
@@ -366,6 +366,8 @@ public class Controller extends Thread {
|
||||
// Entry point
|
||||
|
||||
public static void main(String[] args) {
|
||||
LoggingUtils.fixLegacyLog4j2Properties();
|
||||
|
||||
LOGGER.info("Starting up...");
|
||||
|
||||
// Potential GUI startup with splash screen, etc.
|
||||
|
31
src/main/java/org/qortal/utils/LoggingUtils.java
Normal file
31
src/main/java/org/qortal/utils/LoggingUtils.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package org.qortal.utils;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class LoggingUtils {
|
||||
|
||||
public static void fixLegacyLog4j2Properties() {
|
||||
Path log4j2PropertiesPath = Paths.get("log4j2.properties");
|
||||
if (Files.exists(log4j2PropertiesPath)) {
|
||||
try {
|
||||
String content = FileUtils.readFileToString(log4j2PropertiesPath.toFile(), "UTF-8");
|
||||
if (content.contains("${dirname:-}")) {
|
||||
content = content.replace("${dirname:-}", "./");
|
||||
FileUtils.writeStringToFile(log4j2PropertiesPath.toFile(), content, "UTF-8");
|
||||
|
||||
// Force reload the log4j2.properties file
|
||||
((org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false)).reconfigure();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Not much we can do here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user